From fc6dee414100ec04ced3f02c11eed8682a617391 Mon Sep 17 00:00:00 2001 From: Matias Bjarland Date: Tue, 17 May 2022 10:47:53 +0200 Subject: [PATCH 1/2] In my mind `(apply str (reverse s))` expresses the intent more clearly I think using what is arguably an implementation detail of list (i.e. that it appends at the start) is fine but not as explicit and obvious as `(apply str (reverse s))`. --- tracks/clojure/exercises/reverse-string/mentoring.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tracks/clojure/exercises/reverse-string/mentoring.md b/tracks/clojure/exercises/reverse-string/mentoring.md index b230c2019..07056c6d5 100644 --- a/tracks/clojure/exercises/reverse-string/mentoring.md +++ b/tracks/clojure/exercises/reverse-string/mentoring.md @@ -9,6 +9,13 @@ This exercise is about re-implementing a common library function. ```clojure (ns reverse-string) +(defn reverse-string [s] + (apply str (reverse s))) +``` + +```clojure +(ns reverse-string) + (defn reverse-string [s] (apply str (reduce conj '() s))) ``` @@ -20,6 +27,8 @@ This exercise is about re-implementing a common library function. (apply str (into '() s))) ``` + + ## Common suggestions ## Talking points From fc2ec422b7ae209eb47e73a2be192ec003700097 Mon Sep 17 00:00:00 2001 From: Derk-Jan Karrenbeld Date: Fri, 16 Feb 2024 10:09:09 +0100 Subject: [PATCH 2/2] Update tracks/clojure/exercises/reverse-string/mentoring.md --- tracks/clojure/exercises/reverse-string/mentoring.md | 1 + 1 file changed, 1 insertion(+) diff --git a/tracks/clojure/exercises/reverse-string/mentoring.md b/tracks/clojure/exercises/reverse-string/mentoring.md index 07056c6d5..1674d80e0 100644 --- a/tracks/clojure/exercises/reverse-string/mentoring.md +++ b/tracks/clojure/exercises/reverse-string/mentoring.md @@ -13,6 +13,7 @@ This exercise is about re-implementing a common library function. (apply str (reverse s))) ``` +One may prefer this because the above expresses the intent more clearly. ```clojure (ns reverse-string)