0
votes

When I executed this code

(reduce (fn [final number] (into final (+ number 1))) [] [1 2 3 4 5])

I got this error:

Don't know how to create ISeq from: java.lang.Long

2
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])