Skip to content

Instantly share code, notes, and snippets.

@cwc
Last active August 12, 2016 23:00
Show Gist options
  • Save cwc/92af713a32664d80cd49c890782f9589 to your computer and use it in GitHub Desktop.
Save cwc/92af713a32664d80cd49c890782f9589 to your computer and use it in GitHub Desktop.
Can't use Stream.transform with a map accumulator?
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