Repository: exercism/clojure
Pull request #266 (2019-02-02 20:56:48)

add a restriction for reverse
I just noticed we are not actually mentioning to not use `reverse` there, even if it's even in the community solutions (and the exercise doesn't really make sense using just `reverse`).


Patch:
diff --git a/exercises/proverb/src/example.clj b/exercises/proverb/src/example.clj
index 4c3804b..4bafab3 100644
--- a/exercises/proverb/src/example.clj
+++ b/exercises/proverb/src/example.clj
@@ -1,15 +1,15 @@
 (ns proverb
   (:require [clojure.string :as str]))
 
-(def last-line "And all for the want of a %s.")
+(def subjects ["nail" "shoe" "horse" "rider" "message" "battle" "kingdom"])
+
+(def last-line "And all for the want of a nail.")
 
 (defn- line [[cause-subject effect-subject]]
   (format "For want of a %s the %s was lost." cause-subject effect-subject))
 
-(defn recite [subjects]
-  (if (empty? subjects) ""
-    (->> subjects
-    (partition 2 1)
-    (map line)
-    (#(conj (vec %) (format last-line (first subjects))))
-    (str/join "\n"))))
+(def proverb (->> subjects
+                  (partition 2 1)
+                  (map line)
+                  (#(conj (vec %) last-line))
+                  (str/join "\n")))
diff --git a/exercises/proverb/src/proverb.clj b/exercises/proverb/src/proverb.clj
index 6bd6d76..4a93c4b 100644
--- a/exercises/proverb/src/proverb.clj
+++ b/exercises/proverb/src/proverb.clj
@@ -1,5 +1,3 @@
 (ns proverb)
 
-(defn recite [] ;; <- arglist goes here
-    ;; your code goes here
-)
+(def proverb "")
diff --git a/exercises/reverse-string/README.md b/exercises/reverse-string/README.md
index 44f8f9c..30edc7d 100644
--- a/exercises/reverse-string/README.md
+++ b/exercises/reverse-string/README.md
@@ -5,6 +5,10 @@ Reverse a string
 For example:
 input: "cool"
 output: "looc"
+
+## Restrictions
+You can not use the `reverse` function, but you can use any of the other core functions.
+
 ## Source
 
 Introductory challenge to reverse an input string [https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb](https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb)


Test patch:
diff --git a/exercises/proverb/test/proverb_test.clj b/exercises/proverb/test/proverb_test.clj
index 3afb2ff..ed78074 100644
--- a/exercises/proverb/test/proverb_test.clj
+++ b/exercises/proverb/test/proverb_test.clj
@@ -1,33 +1,10 @@
 (ns proverb-test
   (:require [clojure.test :refer [deftest is]]
-            [proverb :refer [recite]]
+            [proverb :refer [proverb]]
             [clojure.string :as str]))
 
-(deftest zero-pieces
-  (is (=
-        (recite ())
-        "")))
-      
-(deftest one-piece
-  (is (=
-        (recite '("nail"))
-        "And all for the want of a nail.")))
-
-(deftest two-pieces
-  (is (=
-        (recite '("nail" "shoe"))
-        (str/join "\n" ["For want of a nail the shoe was lost."
-                        "And all for the want of a nail."]))))
-
-(deftest three-pieces
-  (is (=
-        (recite '("nail" "shoe" "horse"))
-        (str/join "\n" ["For want of a nail the shoe was lost."
-                        "For want of a shoe the horse was lost."
-                        "And all for the want of a nail."]))))
-
-(deftest full-proverb
-  (is (= (recite '("nail" "shoe" "horse" "rider" "message" "battle" "kingdom"))
+(deftest full-text-is-correct
+  (is (= proverb
          (str/join "\n" ["For want of a nail the shoe was lost."
                          "For want of a shoe the horse was lost."
                          "For want of a horse the rider was lost."
@@ -35,11 +12,3 @@
                          "For want of a message the battle was lost."
                          "For want of a battle the kingdom was lost."
                          "And all for the want of a nail."]))))
-
-(deftest four-pieces-modernized
-  (is (=
-        (recite '("pin" "gun" "soldier" "battle"))
-        (str/join "\n" ["For want of a pin the gun was lost."
-                        "For want of a gun the soldier was lost."
-                        "For want of a soldier the battle was lost."
-                        "And all for the want of a pin."]))))