Search code examples
clojure

Pass values from a collection as the first argument of a function


Say I have a collection of user-ids i.e. [001 002 003], and then I would have a function that does something and requires the user-id as its first argument.

(defn some-function [user-id name e-mail] (do-something user-id name e-mail))

What I'd like to do is to use this "some-function" to go through the collection of user-ids so that it would just change the user-id argument but the other arguments would remain the same i.e. so that it would return the following:

=>

[(some-function 001 name e-mail) (some-function 002 name e-mail) (some-function 003 name e-mail)]

Any help here? :) Thanks!


Solution

  • You can just use map:

    (map #(some-function % name email) user-ids)