Unless this is for learning, it's way shorter to write: (mapv inc [1 2 3 4 5])
- cfrick
2 Answers
8
votes
You need conj instead of into.
into appends a sequence, conj appends an element.
1
votes
Or you can wrap (+ number 1) with vector but using conj would be proper one:
(reduce (fn [final number] (into final [(+ number 1)])) [] [1 2 3 4 5])
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more
(mapv inc [1 2 3 4 5])- cfrick