From 317ea5d2083f5c19a1a45b5c4d89c0f9a7ef9a11 Mon Sep 17 00:00:00 2001 From: Mahmut Surekci Date: Fri, 27 May 2016 15:51:45 +0100 Subject: [PATCH] Reposition MapSets koans. Reposition some of the koans to make it clear why MapSets are interesting. --- lib/koans/{17_map_sets.ex => 10_map_sets.ex} | 24 +++++++++---------- lib/koans/{10_structs.ex => 11_structs.ex} | 0 ...ern_matching.ex => 12_pattern_matching.ex} | 0 .../{12_functions.ex => 13_functions.ex} | 0 lib/koans/{13_enums.ex => 14_enums.ex} | 0 .../{14_processes.ex => 15_processes.ex} | 0 lib/koans/{15_tasks.ex => 16_tasks.ex} | 0 lib/koans/{16_agents.ex => 17_agents.ex} | 0 .../{16_protocols.ex => 18_protocols.ex} | 0 lib/runner.ex | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) rename lib/koans/{17_map_sets.ex => 10_map_sets.ex} (85%) rename lib/koans/{10_structs.ex => 11_structs.ex} (100%) rename lib/koans/{11_pattern_matching.ex => 12_pattern_matching.ex} (100%) rename lib/koans/{12_functions.ex => 13_functions.ex} (100%) rename lib/koans/{13_enums.ex => 14_enums.ex} (100%) rename lib/koans/{14_processes.ex => 15_processes.ex} (100%) rename lib/koans/{15_tasks.ex => 16_tasks.ex} (100%) rename lib/koans/{16_agents.ex => 17_agents.ex} (100%) rename lib/koans/{16_protocols.ex => 18_protocols.ex} (100%) diff --git a/lib/koans/17_map_sets.ex b/lib/koans/10_map_sets.ex similarity index 85% rename from lib/koans/17_map_sets.ex rename to lib/koans/10_map_sets.ex index 41ed908..6777150 100644 --- a/lib/koans/17_map_sets.ex +++ b/lib/koans/10_map_sets.ex @@ -1,21 +1,27 @@ defmodule MapSets do use Koans - @intro "My name is Set, MapSet" + @intro "My name is Set, MapSet." @set MapSet.new([1, 2, 3, 4, 5]) - koan "Does this value exist in the map set?" do - assert MapSet.member?(@set, 3) == ___ - end - - koan "Multiply everything by 3 in my set" do + 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 "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 modified_set = MapSet.put(@set, 6) @@ -44,12 +50,6 @@ defmodule MapSets do assert MapSet.member?(intersection_set, 5) == ___ 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 new_set = MapSet.union(@set, MapSet.new([1, 5, 6, 7])) diff --git a/lib/koans/10_structs.ex b/lib/koans/11_structs.ex similarity index 100% rename from lib/koans/10_structs.ex rename to lib/koans/11_structs.ex diff --git a/lib/koans/11_pattern_matching.ex b/lib/koans/12_pattern_matching.ex similarity index 100% rename from lib/koans/11_pattern_matching.ex rename to lib/koans/12_pattern_matching.ex diff --git a/lib/koans/12_functions.ex b/lib/koans/13_functions.ex similarity index 100% rename from lib/koans/12_functions.ex rename to lib/koans/13_functions.ex diff --git a/lib/koans/13_enums.ex b/lib/koans/14_enums.ex similarity index 100% rename from lib/koans/13_enums.ex rename to lib/koans/14_enums.ex diff --git a/lib/koans/14_processes.ex b/lib/koans/15_processes.ex similarity index 100% rename from lib/koans/14_processes.ex rename to lib/koans/15_processes.ex diff --git a/lib/koans/15_tasks.ex b/lib/koans/16_tasks.ex similarity index 100% rename from lib/koans/15_tasks.ex rename to lib/koans/16_tasks.ex diff --git a/lib/koans/16_agents.ex b/lib/koans/17_agents.ex similarity index 100% rename from lib/koans/16_agents.ex rename to lib/koans/17_agents.ex diff --git a/lib/koans/16_protocols.ex b/lib/koans/18_protocols.ex similarity index 100% rename from lib/koans/16_protocols.ex rename to lib/koans/18_protocols.ex diff --git a/lib/runner.ex b/lib/runner.ex index 35bab7c..ac87ae5 100644 --- a/lib/runner.ex +++ b/lib/runner.ex @@ -9,6 +9,7 @@ defmodule Runner do Lists, KeywordLists, Maps, + MapSets, Structs, PatternMatching, Functions, @@ -17,7 +18,6 @@ defmodule Runner do Tasks, Agents, Protocols, - MapSets, ] def koan?(koan), do: Enum.member?(@modules, koan)