How to apply a function with two arguments to a sequence?

I have a sequence:

[a b c ...]

And the function (f x y). I want to get the following:

(f c (f b (f a 1)))

Etc .. How to do this?

+5
source share
2 answers

Reduce, with a little adaptation:

(reduce #(f %2 %1) 1 [a b c])
+11
source
(reduce (fn [acc x] (f x acc)) 1 [a b c d])
+2
source

All Articles