Reposition MapSets koans. Reposition some of the koans to make it clear why MapSets are interesting.
This commit is contained in:
@@ -1,21 +1,27 @@
|
|||||||
defmodule MapSets do
|
defmodule MapSets do
|
||||||
use Koans
|
use Koans
|
||||||
|
|
||||||
@intro "My name is Set, MapSet"
|
@intro "My name is Set, MapSet."
|
||||||
|
|
||||||
@set MapSet.new([1, 2, 3, 4, 5])
|
@set MapSet.new([1, 2, 3, 4, 5])
|
||||||
|
|
||||||
koan "Does this value exist in the map set?" do
|
koan "I am merely another collection but, you can perform some operations on me" do
|
||||||
assert MapSet.member?(@set, 3) == ___
|
|
||||||
end
|
|
||||||
|
|
||||||
koan "Multiply everything by 3 in my set" do
|
|
||||||
new_set = MapSet.new(@set, fn x -> 3 * x end)
|
new_set = MapSet.new(@set, fn x -> 3 * x end)
|
||||||
|
|
||||||
assert MapSet.member?(new_set, 15) == ___
|
assert MapSet.member?(new_set, 15) == ___
|
||||||
assert MapSet.member?(new_set, 1) == ___
|
assert MapSet.member?(new_set, 1) == ___
|
||||||
end
|
end
|
||||||
|
|
||||||
|
koan "However, I do not allow duplication" do
|
||||||
|
new_set = MapSet.new([1, 1, 2, 3, 3, 3])
|
||||||
|
|
||||||
|
assert MapSet.size(new_set) == ___
|
||||||
|
end
|
||||||
|
|
||||||
|
koan "Does this value exist in the map set?" do
|
||||||
|
assert MapSet.member?(@set, 3) == ___
|
||||||
|
end
|
||||||
|
|
||||||
koan "Add this value into a map set" do
|
koan "Add this value into a map set" do
|
||||||
modified_set = MapSet.put(@set, 6)
|
modified_set = MapSet.put(@set, 6)
|
||||||
|
|
||||||
@@ -44,12 +50,6 @@ defmodule MapSets do
|
|||||||
assert MapSet.member?(intersection_set, 5) == ___
|
assert MapSet.member?(intersection_set, 5) == ___
|
||||||
end
|
end
|
||||||
|
|
||||||
koan "Duplication is a no-no" do
|
|
||||||
new_set = MapSet.new([1, 1, 2, 3, 3])
|
|
||||||
|
|
||||||
assert MapSet.size(new_set) == ___
|
|
||||||
end
|
|
||||||
|
|
||||||
koan "Unify my sets" do
|
koan "Unify my sets" do
|
||||||
new_set = MapSet.union(@set, MapSet.new([1, 5, 6, 7]))
|
new_set = MapSet.union(@set, MapSet.new([1, 5, 6, 7]))
|
||||||
|
|
||||||
@@ -9,6 +9,7 @@ defmodule Runner do
|
|||||||
Lists,
|
Lists,
|
||||||
KeywordLists,
|
KeywordLists,
|
||||||
Maps,
|
Maps,
|
||||||
|
MapSets,
|
||||||
Structs,
|
Structs,
|
||||||
PatternMatching,
|
PatternMatching,
|
||||||
Functions,
|
Functions,
|
||||||
@@ -17,7 +18,6 @@ defmodule Runner do
|
|||||||
Tasks,
|
Tasks,
|
||||||
Agents,
|
Agents,
|
||||||
Protocols,
|
Protocols,
|
||||||
MapSets,
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def koan?(koan), do: Enum.member?(@modules, koan)
|
def koan?(koan), do: Enum.member?(@modules, koan)
|
||||||
|
|||||||
Reference in New Issue
Block a user