Last active
August 12, 2016 23:00
-
-
Save cwc/92af713a32664d80cd49c890782f9589 to your computer and use it in GitHub Desktop.
Can't use Stream.transform with a map accumulator?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iex(1)> list = [1,2,3] | |
[1,2,3] | |
iex(2)> Stream.transform(list, fn -> %{} end, fn (x, a) -> Map.put(a, x, "#{x}") end, fn (map) -> Map.values(map) end) |> Enum.to_list | |
** (TryClauseError) no try clause matching: %{1 => "1"} | |
(elixir) lib/stream.ex:739: Stream.do_transform/8 | |
(elixir) lib/enum.ex:1636: Enum.reduce/3 | |
(elixir) lib/enum.ex:2346: Enum.to_list/1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment