Return to Snippet

Revision: 22067
at December 30, 2009 17:39 by narkisr


Initial Code
; creating a list of functions from fns 
(defn juxt [& fns]
  (fn[ & arg] (map #(apply % args) fns))) 

; a simple map
(def test-map {:a "1" :b "2" :c "3" :d "4"})

; applying two functions at once which results with ("1" "3") 
((juxt :a :c) test-map)

; applying both identity & square on the range values, 
; result with ((1 1) (2 4) (3 9) (4 16) (5 25)) 
((partial map (juxt identity #(* % %))) (range 1 6))

Initial URL
http://groups.google.com/group/clojure/browse_thread/thread/c960ec89bd0a85ac

Initial Description
A nice function which creates a list of function that can be applied during a map.

Initial Title
juxt(apose) function

Initial Tags


Initial Language
Clojure