From bc9113fe605ccb7bce2268d9fb904e1f5d7d4f52 Mon Sep 17 00:00:00 2001 From: Colin Jones Date: Tue, 8 Feb 2011 07:20:38 -0600 Subject: [PATCH] Tweak wording very slightly for new macros koans. --- src/koans/macros.clj | 22 ++++++++-------------- src/path_to_answer_sheet.clj | 15 +++++++-------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/koans/macros.clj b/src/koans/macros.clj index a72d835..644430f 100644 --- a/src/koans/macros.clj +++ b/src/koans/macros.clj @@ -1,18 +1,14 @@ -"Macros are also just functions!" (defmacro hello [x] (str "Hello, " x)) - "Create a list and use it to be eval-ed at run time" (defmacro infix [form] (list (second form) (first form) (nth form 2))) -"Sometimes it is easier to handcraft it ..." (defmacro infix-better [form] `(~(second form) __ __ )) -"Macro in a macro until you get a stack overflow! ;)" (defmacro r-infix [form] (list (second form) (if (instance? clojure.lang.PersistentList (first form)) @@ -25,23 +21,21 @@ (meditations - "Macros are just function eval-ed at compile time" - (= "Hello, Macros!" (hello "Macros!")) - + "Macros are like functions created at compile time" + (= __ (hello "Macros!")) + "Can I haz some infix?" (= __ (infix (9 + 1))) - - "Remember these are nothing but code transformations" + + "Remember, these are nothing but code transformations" (= __ (macroexpand '(infix (9 + 1)))) - "You can do better than that, hand crafting ftw" + "You can do better than that, hand crafting ftw!" (= __ (macroexpand '(infix-better (10 * 2)))) - + "Things dont always work as you would like them to... " (= __ (macroexpand '(infix-better ( 10 + (2 * 3))))) "Really, you dont understand recursion until you understand recursion" - (= __ (r-infix (10 + (2 * 3)))) - - ) + (= __ (r-infix (10 + (2 * 3))))) diff --git a/src/path_to_answer_sheet.clj b/src/path_to_answer_sheet.clj index 3ea42e9..9bd4e08 100644 --- a/src/path_to_answer_sheet.clj +++ b/src/path_to_answer_sheet.clj @@ -135,14 +135,13 @@ '(fn [x] (+ 20 x))]} "macros" {"__" ['~(first form) - '~(nth form 2) - 10 - ''(+ 9 1) - ''(* 10 2) - ''(+ 10 (2 * 3)) - 16 - ] - } + '~(nth form 2) + "Hello, Macros!" + 10 + ''(+ 9 1) + ''(* 10 2) + ''(+ 10 (2 * 3)) + 16]} }) (defn replace-with [s k replacements]