Demonstrating MapSets similarity to List using Enum.fetch. Koan added to demonstrate MapSets being unordered after 32.

This commit is contained in:
Mahmut Surekci
2016-05-27 18:44:47 +01:00
parent 925f6ba2f7
commit 48df8ad8af
2 changed files with 17 additions and 7 deletions

View File

@@ -5,12 +5,9 @@ defmodule MapSets do
@set MapSet.new([1, 2, 3, 4, 5])
koan "I am merely another collection but, you can perform some operations on me" do
new_set = MapSet.new(@set, fn x -> 3 * x end)
assert MapSet.member?(new_set, 15) == ___
assert MapSet.member?(new_set, 1) == ___
end
koan "I am very similar to a list" do
assert Enum.fetch(@set, 0) == {:ok, ___}
end
koan "However, I do not allow duplication" do
new_set = MapSet.new([1, 1, 2, 3, 3, 3])
@@ -18,6 +15,17 @@ defmodule MapSets do
assert MapSet.size(new_set) == ___
end
koan "Even though I am like a list I am unordered after 32 elements" do
assert 1..33 |> MapSet.new() |> Enum.fetch(0) == {___, 11}
end
koan "I am merely another collection but, you can perform some operations on me" do
new_set = MapSet.new(@set, fn x -> 3 * x end)
assert MapSet.member?(new_set, 15) == ___
assert MapSet.member?(new_set, 1) == ___
end
koan "Does this value exist in the map set?" do
assert MapSet.member?(@set, 3) == ___
end