0

I have a function which takes a sequence of function and a sequence of arguments. This should return a vector with the results of each function applied to the sequence of the arguments.

((solution + max min) 2 3 5 1 6 4) ;;--> [21 6 1]

Im trying to solve it with reduce but i dont know how to apply all functions it works only for the first function:

(defn solution
  [& args]
 (fn [& args2]
 (reduce (first args) [] args2)))

1 Answer 1

4

Use juxt:

((juxt + max min) 2 3 5 1 6 4)
=> [21 6 1]

Or define function solution:

(defn solution
  [& args]
  (fn [& args2]
    (apply (apply juxt args) args2)))

((solution + max min) 2 3 5 1 6 4)
=> [21 6 1]
Sign up to request clarification or add additional context in comments.

1 Comment

Well, (def solution juxt) would do to define solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.