Skip to content

Instantly share code, notes, and snippets.

@ekhall
Last active August 29, 2015 13:57
Show Gist options
  • Save ekhall/9630990 to your computer and use it in GitHub Desktop.
Save ekhall/9630990 to your computer and use it in GitHub Desktop.
Understanding &Enum.reduce/3
iex(11)> Enum.reduce([1, 2, 3, 4, 5], 0, fn(x, acc) -> IO.puts "x: #{x} acc: #{acc}";x + acc end)
x: 1 acc: 0
x: 2 acc: 1
x: 3 acc: 3
x: 4 acc: 6
x: 5 acc: 10
15
iex(12)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment