From 8b445fb6d5d468cadaa74bd5be91cc73fbc450db Mon Sep 17 00:00:00 2001 From: Matias Bjarland Date: Fri, 16 Feb 2024 10:09:17 +0100 Subject: [PATCH] [Clojure]: reverse-string: Mentor note update (#2191) * 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))`. * Update tracks/clojure/exercises/reverse-string/mentoring.md --------- Co-authored-by: Derk-Jan Karrenbeld --- tracks/clojure/exercises/reverse-string/mentoring.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tracks/clojure/exercises/reverse-string/mentoring.md b/tracks/clojure/exercises/reverse-string/mentoring.md index b230c2019..1674d80e0 100644 --- a/tracks/clojure/exercises/reverse-string/mentoring.md +++ b/tracks/clojure/exercises/reverse-string/mentoring.md @@ -9,6 +9,14 @@ This exercise is about re-implementing a common library function. ```clojure (ns reverse-string) +(defn reverse-string [s] + (apply str (reverse s))) +``` + +One may prefer this because the above expresses the intent more clearly. +```clojure +(ns reverse-string) + (defn reverse-string [s] (apply str (reduce conj '() s))) ``` @@ -20,6 +28,8 @@ This exercise is about re-implementing a common library function. (apply str (into '() s))) ``` + + ## Common suggestions ## Talking points