I am learning clojure and I am having problem understanding this clojure code, so I have this partial function
(def add-five (partial + 5))
When I run,
(add-five 2)# I get 7
(add-five 2 5) # I get 12
For first, I give one argument; For second, I give two arguments.
(map add-five [1 2 3 4 5])
this gives me
(6 7 8 9 10)
Here, I am assuming, add-five is being applied element of the list. However when I run,
(reduce add-five [1 2 3 4 5])
, I have no idea what is happening?
(reduce add-five [0]) #gives me zero
(reduce add-five [0 0]) #gives me five
Can someone explain what happens what I run the reduce like above?