Skip to content

Commit

Permalink
[Clojure]: reverse-string: Mentor note update (#2191)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
mbjarland and SleeplessByte authored Feb 16, 2024
1 parent ac64ab1 commit 8b445fb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tracks/clojure/exercises/reverse-string/mentoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
```
Expand All @@ -20,6 +28,8 @@ This exercise is about re-implementing a common library function.
(apply str (into '() s)))
```



## Common suggestions

## Talking points
Expand Down

0 comments on commit 8b445fb

Please sign in to comment.