Creating a collection of functions
clojure, collections, higher-order-functions
Solution
I'm not entirely clear what you are trying to do, but perhaps you want something like:
(map #(partial bar %) [1 2 3])
This will create a sequence of functions, which when called (with 0 arguments) will do the equivalent of `(bar 1)`, `(bar 2)` etc.
Problem
I have the following function that receives a list of functions: ``` (defn foo [fn-list] (map #(%) fn-list)) ``` I want to pass it instances of this `bar` function as a parameter. ``` (defn bar [x] (println x)) ``` My problem is that I only have a list of arguments for `bar`. Fox example, a simple list `("a" "b" "c")`. I want to create a list of `bar` functions, each having as argument, an element of the later collection. Can someone show me how this can be done? Thanks. Note: I can't simply replace `foo` with `(map bar ("a" "b" "c"))` for reasonable reasons.