Modify koans and descriptions
This commit is contained in:
@@ -1,12 +1,9 @@
|
|||||||
defmodule Comprehensions do
|
defmodule Comprehensions do
|
||||||
use Koans
|
use Koans
|
||||||
|
|
||||||
@intro "Comprehensions"
|
@intro "A comprehension is made of three parts: generators, filters, and collectibles. We will look at how these interact with eachother"
|
||||||
|
|
||||||
# A comprehension is made of three parts: generators, filters and collectables.
|
koan "The generator, `n <- [1, 2, 3, 4]`, is providing the values for our comprehension" do
|
||||||
|
|
||||||
koan "Generators provide the values to be used in a comprehension" do
|
|
||||||
# In the expression below, `n <- [1, 2, 3, 4]` is the generator.
|
|
||||||
assert (for n <- [1, 2, 3, 4], do: n * n) == ___
|
assert (for n <- [1, 2, 3, 4], do: n * n) == ___
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -20,7 +17,7 @@ defmodule Comprehensions do
|
|||||||
end
|
end
|
||||||
|
|
||||||
koan "You can use multiple generators at once" do
|
koan "You can use multiple generators at once" do
|
||||||
assert (for x <- [2, 4], y <- ["dogs", "cats"], do: "#{x} #{y}") == ___
|
assert (for x <- ["little", "big"], y <- ["dogs", "cats"], do: "#{x} #{y}") == ___
|
||||||
end
|
end
|
||||||
|
|
||||||
koan "Use a filter to reduce your work" do
|
koan "Use a filter to reduce your work" do
|
||||||
@@ -28,9 +25,9 @@ defmodule Comprehensions do
|
|||||||
end
|
end
|
||||||
|
|
||||||
koan "Add the result of a comprehension to an existing collection" do
|
koan "Add the result of a comprehension to an existing collection" do
|
||||||
pies = ["Apple Pie"]
|
collection = ["Apple Pie"]
|
||||||
pies = for x <- ["Pecan", "Pumpkin"], into: pies, do: "#{x} Pie"
|
collection = for x <- ["Pecan", "Pumpkin"], into: collection, do: "#{x} Pie"
|
||||||
assert pies == ___
|
assert collection == ___
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ defmodule ComprehensionsTests do
|
|||||||
[1, 4, 9, 16],
|
[1, 4, 9, 16],
|
||||||
[1, 4, 9, 16],
|
[1, 4, 9, 16],
|
||||||
["Hello World", "Apple Pie"],
|
["Hello World", "Apple Pie"],
|
||||||
["2 dogs", "2 cats", "4 dogs", "4 cats"],
|
["little dogs", "little cats", "big dogs", "big cats"],
|
||||||
[4, 5, 6],
|
[4, 5, 6],
|
||||||
["Apple Pie", "Pecan Pie", "Pumpkin Pie"],
|
["Apple Pie", "Pecan Pie", "Pumpkin Pie"],
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user