z7sg Ѫ
z7sg Ѫ

Reputation: 3203

How can I reduce a list of arguments, instead of a collection?

Is there a function in clojure that takes two or more arguments and supplies them to a function, so f(f(f(a, b), c), d) etc.

I know I can do something like this:

(fn g [& items] (reduce f (seq items)))

But is there a better way to do it?

Upvotes: 3

Views: 100

Answers (1)

Jan
Jan

Reputation: 11726

That's exactly how you should do it. In fact removing seq would make it even simpler without changing the behaviour.

Upvotes: 4

Related Questions