fixes typos and some formatting
This commit is contained in:
@@ -53,7 +53,7 @@ defmodule Lists do
|
||||
assert List.insert_at([1, 2, 3], 10, 4) == ___
|
||||
end
|
||||
|
||||
koan "Sometimes its faster to loop around back" do
|
||||
koan "Sometimes it's faster to loop around back" do
|
||||
assert List.insert_at([1, 2, 3], -1, 4) == ___
|
||||
end
|
||||
|
||||
|
@@ -22,11 +22,11 @@ defmodule Maps do
|
||||
assert Map.fetch(@person, :age) == ___
|
||||
end
|
||||
|
||||
koan "Or the atom :error when it doesnt" do
|
||||
koan "Or the atom :error when it doesn't" do
|
||||
assert Map.fetch(@person, :family) == ___
|
||||
end
|
||||
|
||||
koan "Extending a map is a simple as putting in a new pair" do
|
||||
koan "Extending a map is as simple as adding a new pair" do
|
||||
person_with_hobby = Map.put(@person, :hobby, "Kayaking")
|
||||
assert Map.fetch(person_with_hobby, :hobby) == ___
|
||||
end
|
||||
|
@@ -49,7 +49,6 @@ defmodule Structs do
|
||||
assert plane?(%Person{}) == ___
|
||||
end
|
||||
|
||||
|
||||
koan "Are basically maps" do
|
||||
silvia = %Person{age: 22, name: "Silvia"}
|
||||
|
||||
|
@@ -10,7 +10,7 @@ defmodule Functions do
|
||||
end
|
||||
|
||||
def multiply(a, b), do: a * b
|
||||
koan "Single line functions are cool, but mind the command and the colon!" do
|
||||
koan "Single line functions are cool, but mind the comma and the colon!" do
|
||||
assert multiply(2, ___) == 6
|
||||
end
|
||||
|
||||
@@ -34,12 +34,12 @@ defmodule Functions do
|
||||
def sum_up(thing) when is_list(thing), do: :entire_list
|
||||
def sum_up(_thing), do: :single_thing
|
||||
|
||||
koan "Functions can be picky and apply to only certain types" do
|
||||
koan "Functions can be picky and apply only to certain types" do
|
||||
assert sum_up([1,2,3]) == ___
|
||||
assert sum_up(1) == ___
|
||||
end
|
||||
|
||||
def bigger(a,b) when a > b, do: "#{a} is bigger than #{b}"
|
||||
def bigger(a,b) when a > b, do: "#{a} is bigger than #{b}"
|
||||
def bigger(a,b) when a <= b, do: "#{a} is not bigger than #{b}"
|
||||
|
||||
koan "Intricate guards are possible, but be mindful of the reader" do
|
||||
@@ -68,7 +68,7 @@ defmodule Functions do
|
||||
def times_five_and_then(number, fun), do: fun.(number*5)
|
||||
def square(number), do: number * number
|
||||
|
||||
koan "You can pass functions around as arguments. Place and '&' before the name and state the arity" do
|
||||
koan "You can pass functions around as arguments. Place an '&' before the name and state the arity" do
|
||||
assert times_five_and_then(2, &square/1) == ___
|
||||
end
|
||||
|
||||
|
@@ -16,7 +16,7 @@ defmodule Enums do
|
||||
end
|
||||
|
||||
def even?(n), do: rem(n, 2) == 0
|
||||
koan "Sometimes you you just want to know if there are any elements fullfilling a condition" do
|
||||
koan "Sometimes you just want to know if there are any elements fulfilling a condition" do
|
||||
assert Enum.any?([1,2,3], &even?/1) == ___
|
||||
assert Enum.any?([1,3,5], &even?/1) == ___
|
||||
end
|
||||
|
@@ -32,7 +32,7 @@ defmodule Processes do
|
||||
spawn(fn -> receive do
|
||||
_anything -> flunk "I really wasn't expecting messages"
|
||||
after
|
||||
10 -> send parent, {:waited_too_long, "I am inpatient"}
|
||||
10 -> send parent, {:waited_too_long, "I am impatient"}
|
||||
end
|
||||
end)
|
||||
|
||||
|
@@ -2,7 +2,7 @@ defmodule Tasks do
|
||||
use Koans
|
||||
|
||||
koan "Tasks can be used for asynchronous computations with results" do
|
||||
task = Task.async(fn -> 3 *3 end)
|
||||
task = Task.async(fn -> 3 * 3 end)
|
||||
do_other_stuff()
|
||||
assert Task.await(task) + 1 == ___
|
||||
end
|
||||
|
@@ -15,7 +15,7 @@ defmodule Agents do
|
||||
assert Agent.get(__MODULE__, &(&1)) == ___
|
||||
end
|
||||
|
||||
koan "Use get_and_update when you need read and change a value in one go" do
|
||||
koan "Use get_and_update when you need to read and change a value in one go" do
|
||||
Agent.start_link(fn() -> ["Milk"] end, name: __MODULE__)
|
||||
|
||||
old_list = Agent.get_and_update(__MODULE__, fn(old) ->
|
||||
|
Reference in New Issue
Block a user