Created
March 14, 2013 03:53
-
-
Save jcoyne/5158691 to your computer and use it in GitHub Desktop.
I'm trying to write Ruby's inject method in Elixir.
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
defmodule Foo do | |
def bar(acc, [H | T]) do | |
acc + H + bar(T) | |
end | |
def bar(acc, []) do | |
acc | |
end | |
end | |
Foo.bar(7, [1, 2, 3]) | |
** (FunctionClauseError) no function clause matching: Foo.bar(7, [1,2,3]) | |
iex:110: Foo.bar(7, [1,2,3]) | |
erl_eval.erl:569: :erl_eval.do_apply/6 | |
src/elixir.erl:133: :elixir.eval_forms/3 | |
/private/tmp/elixir-Zrrr/elixir-lang-elixir-90ff71b/lib/iex/lib/iex/server.ex:19: IEx.Server.do_loop/1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment