Skip to content

Instantly share code, notes, and snippets.

@moccos
Last active April 25, 2016 08:38
Show Gist options
  • Save moccos/924204deb3b9b2f82eacf9c50219ecae to your computer and use it in GitHub Desktop.
Save moccos/924204deb3b9b2f82eacf9c50219ecae to your computer and use it in GitHub Desktop.
f1 = fn x ->
IO.puts(" #{x} -> #{x + 1}")
x + 1
end
list = [10, 20]
list
|> Enum.map(&(f1.(&1)))
|> Enum.map(&(f1.(&1)))
|> Enum.map(&(f1.(&1)))
|> IO.inspect
list
|> Stream.map(&(f1.(&1)))
|> Stream.map(&(f1.(&1)))
|> Enum.map(&(f1.(&1)))
|> IO.inspect
% elixir StreamEnum.exs
10 -> 11
20 -> 21
11 -> 12
21 -> 22
12 -> 13
22 -> 23
[13, 23]
10 -> 11
11 -> 12
12 -> 13
20 -> 21
21 -> 22
22 -> 23
[13, 23]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment