fixes typos and some formatting

This commit is contained in:
Rabea Gleissner
2016-04-22 15:04:59 +01:00
parent 52ac7955e5
commit ee084b4563
8 changed files with 11 additions and 12 deletions

View File

@@ -53,7 +53,7 @@ defmodule Lists do
assert List.insert_at([1, 2, 3], 10, 4) == ___ assert List.insert_at([1, 2, 3], 10, 4) == ___
end 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) == ___ assert List.insert_at([1, 2, 3], -1, 4) == ___
end end

View File

@@ -22,11 +22,11 @@ defmodule Maps do
assert Map.fetch(@person, :age) == ___ assert Map.fetch(@person, :age) == ___
end 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) == ___ assert Map.fetch(@person, :family) == ___
end 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") person_with_hobby = Map.put(@person, :hobby, "Kayaking")
assert Map.fetch(person_with_hobby, :hobby) == ___ assert Map.fetch(person_with_hobby, :hobby) == ___
end end

View File

@@ -49,7 +49,6 @@ defmodule Structs do
assert plane?(%Person{}) == ___ assert plane?(%Person{}) == ___
end end
koan "Are basically maps" do koan "Are basically maps" do
silvia = %Person{age: 22, name: "Silvia"} silvia = %Person{age: 22, name: "Silvia"}

View File

@@ -10,7 +10,7 @@ defmodule Functions do
end end
def multiply(a, b), do: a * b 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 assert multiply(2, ___) == 6
end end
@@ -34,12 +34,12 @@ defmodule Functions do
def sum_up(thing) when is_list(thing), do: :entire_list def sum_up(thing) when is_list(thing), do: :entire_list
def sum_up(_thing), do: :single_thing 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,2,3]) == ___
assert sum_up(1) == ___ assert sum_up(1) == ___
end 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}" 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 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 times_five_and_then(number, fun), do: fun.(number*5)
def square(number), do: number * number 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) == ___ assert times_five_and_then(2, &square/1) == ___
end end

View File

@@ -16,7 +16,7 @@ defmodule Enums do
end end
def even?(n), do: rem(n, 2) == 0 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,2,3], &even?/1) == ___
assert Enum.any?([1,3,5], &even?/1) == ___ assert Enum.any?([1,3,5], &even?/1) == ___
end end

View File

@@ -32,7 +32,7 @@ defmodule Processes do
spawn(fn -> receive do spawn(fn -> receive do
_anything -> flunk "I really wasn't expecting messages" _anything -> flunk "I really wasn't expecting messages"
after after
10 -> send parent, {:waited_too_long, "I am inpatient"} 10 -> send parent, {:waited_too_long, "I am impatient"}
end end
end) end)

View File

@@ -2,7 +2,7 @@ defmodule Tasks do
use Koans use Koans
koan "Tasks can be used for asynchronous computations with results" do 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() do_other_stuff()
assert Task.await(task) + 1 == ___ assert Task.await(task) + 1 == ___
end end

View File

@@ -15,7 +15,7 @@ defmodule Agents do
assert Agent.get(__MODULE__, &(&1)) == ___ assert Agent.get(__MODULE__, &(&1)) == ___
end 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__) Agent.start_link(fn() -> ["Milk"] end, name: __MODULE__)
old_list = Agent.get_and_update(__MODULE__, fn(old) -> old_list = Agent.get_and_update(__MODULE__, fn(old) ->