> Given a collection of functions
>
> (def fs [#(* % 10) #(+ % 1)])
>
> and some numbers
>
> (def c [1 2 3])
>
> How do I apply all the functions to c so that the results of one
> function are passed to the other. In the same way -> works. Thus in
> this case the expected result would be: 11 21 31

A typical use-case for map & comp -

(map (apply comp (reverse fs)) c)
; => (11 21 31)

The `reverse` is necessary because `comp` applies functions right to
left. If you define `fs` as [#(+ % 1) #(* % 10)], you don't need the
`reverse`.

Hope this helps.

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to