diff --git a/lib/koans/13_functions.ex b/lib/koans/13_functions.ex index 8fee618..a3add93 100644 --- a/lib/koans/13_functions.ex +++ b/lib/koans/13_functions.ex @@ -67,6 +67,16 @@ defmodule Functions do assert multiply.(2,3) == ___ end + koan "Prefix a string with & to build a simple anonymous greet function" do + greet = &"Hello, #{&1}!" + assert greet("Foo") == ___ + end + + koan "You can build anonymous functions out of any elixir expression by prefixing it with &" do + three_times = &[&1, &1, &1] + assert three_times.("foo") == ___ + end + def times_five_and_then(number, fun), do: fun.(number*5) def square(number), do: number * number diff --git a/test/koans/functions_koans_test.exs b/test/koans/functions_koans_test.exs index 48b0818..ed96de4 100644 --- a/test/koans/functions_koans_test.exs +++ b/test/koans/functions_koans_test.exs @@ -13,6 +13,8 @@ defmodule FunctionsTests do {:multiple, ["The number was zero", "The number was 5"]}, 6, 6, + "Hello, Foo!", + ["foo", "foo", "foo"], 100, 1000, "Full Name",