Skip to content

Instantly share code, notes, and snippets.

@y-temp4
Last active November 29, 2016 13:26
Show Gist options
  • Save y-temp4/89dec5041f18392a179715f274b41893 to your computer and use it in GitHub Desktop.
Save y-temp4/89dec5041f18392a179715f274b41893 to your computer and use it in GitHub Desktop.
プログラミングにおけるアキュムレータとは何か? ref: http://qiita.com/y-temp4/items/08063349e6f965633663
1..10 |> Enum.to_list |> MyList.sum(0) # 55
1..10 |> Enum.to_list |> MyList.sum # 55
defmodule MyList do
def sum([]), do: 0
def sum([ head | tail ]), do: head + sum(tail)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment