From cf4162ece6702cc3ad21a00d778d5a58d8546aef Mon Sep 17 00:00:00 2001 From: Colin Jones Date: Sat, 6 Nov 2010 17:38:31 -0500 Subject: [PATCH] Short start on destructuring. --- ideaboard.txt | 1 - src/koans/destructuring.clj | 4 ++++ src/path_to_answer_sheet.clj | 1 + src/path_to_enlightenment.clj | 3 ++- 4 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 src/koans/destructuring.clj diff --git a/ideaboard.txt b/ideaboard.txt index 29488dc..2305531 100644 --- a/ideaboard.txt +++ b/ideaboard.txt @@ -4,7 +4,6 @@ immutability/side effects state identity lifetime memoization lazy sequences -recursion recursive list processing trampolining reflection diff --git a/src/koans/destructuring.clj b/src/koans/destructuring.clj new file mode 100644 index 0000000..72a4958 --- /dev/null +++ b/src/koans/destructuring.clj @@ -0,0 +1,4 @@ +(meditations + "Destructuring allows you to break up arguments" + (= __ ((fn [[a b]] (str b a)) + [:foo :bar]))) diff --git a/src/path_to_answer_sheet.clj b/src/path_to_answer_sheet.clj index f410ecd..ba2f1ff 100644 --- a/src/path_to_answer_sheet.clj +++ b/src/path_to_answer_sheet.clj @@ -94,6 +94,7 @@ (if (zero? n) acc (recur (dec n) (* acc n))))]} + "destructuring" {"__" ["\":bar:foo\""]} }) (defn replace-with [s k replacements] diff --git a/src/path_to_enlightenment.clj b/src/path_to_enlightenment.clj index 4d24dfe..36df1a3 100644 --- a/src/path_to_enlightenment.clj +++ b/src/path_to_enlightenment.clj @@ -26,7 +26,8 @@ "runtime_polymorphism" "sequence_comprehensions" "partial_functions" - "recursion"]) + "recursion" + "destructuring"]) (defn run [] (apply load (doall (map (partial str "koans/") ordered-koans)))