Merge pull request #174 from elixirkoans/iamvery/tweaks-to-pr-170
Tweaks to #170 MapSet example
This commit is contained in:
@@ -15,8 +15,22 @@ defmodule MapSets do
|
|||||||
assert MapSet.size(new_set) == ___
|
assert MapSet.size(new_set) == ___
|
||||||
end
|
end
|
||||||
|
|
||||||
koan "Even though I am like a list I am unordered after 32 elements" do
|
def sorted?(set) do
|
||||||
assert 1..33 |> MapSet.new() |> Enum.fetch(0) == {___, 11}
|
list = MapSet.to_list(set)
|
||||||
|
sorted = Enum.sort(list)
|
||||||
|
list == sorted
|
||||||
|
end
|
||||||
|
|
||||||
|
koan "You cannot depend on my order" do
|
||||||
|
new_set = MapSet.new(1..33)
|
||||||
|
assert sorted?(new_set) == ___
|
||||||
|
|
||||||
|
# Note: The number "33" is actually special here. Erlang uses a different
|
||||||
|
# implementation for maps after 32 elements which does not maintain order.
|
||||||
|
# http://stackoverflow.com/a/40408469
|
||||||
|
|
||||||
|
# What do you think this answer to this assertion is?
|
||||||
|
assert sorted?(@set) == ___
|
||||||
end
|
end
|
||||||
|
|
||||||
koan "Does this value exist in the map set?" do
|
koan "Does this value exist in the map set?" do
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ defmodule MapSetsTest do
|
|||||||
answers = [
|
answers = [
|
||||||
1,
|
1,
|
||||||
3,
|
3,
|
||||||
:ok,
|
{:multiple, [false, true]},
|
||||||
true,
|
true,
|
||||||
{:multiple, [true, false]},
|
{:multiple, [true, false]},
|
||||||
true,
|
true,
|
||||||
|
|||||||
Reference in New Issue
Block a user