From 98b7ab99fe2e318065be56abaa722287a2a4901a Mon Sep 17 00:00:00 2001 From: Colin Jones Date: Mon, 8 Nov 2010 17:27:18 -0600 Subject: [PATCH] Add another simple destructuring example. --- ideaboard.txt | 1 + src/koans/destructuring.clj | 11 +++++++++-- src/path_to_answer_sheet.clj | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ideaboard.txt b/ideaboard.txt index 2305531..2e216b0 100644 --- a/ideaboard.txt +++ b/ideaboard.txt @@ -34,6 +34,7 @@ partition-by rand-nth range reductions +constantly repeatedly shuffle diff --git a/src/koans/destructuring.clj b/src/koans/destructuring.clj index 72a4958..b5a7957 100644 --- a/src/koans/destructuring.clj +++ b/src/koans/destructuring.clj @@ -1,4 +1,11 @@ (meditations - "Destructuring allows you to break up arguments" + "Destructuring is an arbiter: it breaks up arguments" (= __ ((fn [[a b]] (str b a)) - [:foo :bar]))) + [:foo :bar])) + + "Whether in function definitions" + (= "First comes love, then comes marriage, then comes Clojure with the baby carriage" + ((fn [[a b c]] __) + ["love" "marriage" "Clojure"])) + +) diff --git a/src/path_to_answer_sheet.clj b/src/path_to_answer_sheet.clj index 72a4d53..d7e49f2 100644 --- a/src/path_to_answer_sheet.clj +++ b/src/path_to_answer_sheet.clj @@ -96,7 +96,8 @@ acc (recur (dec n) (* acc n))))] "___" ['not]} - "destructuring" {"__" ["\":bar:foo\""]} + "destructuring" {"__" ["\":bar:foo\"" + '(format "First comes %s, then comes %s, then comes %s with the baby carriage" a b c) ]} }) (defn replace-with [s k replacements]