((comp (partial apply reduce conj) (juxt (comp first list) (comp range second list))) [:a :b :c] 4)
[:a :b :c 0 1 2 3]
(apply map (juxt #(into %1 %2) #(into %2 %1)) (repeatedly 2 #(shuffle [nil () [] {} #{}])))
([{} nil] [#{} #{}] [() {}] [[] ()] [nil []])
(map (juxt seq? sequential?) [(list 1 2 3) (vector 1 2 3) {:x 1} (seq {:x 1})])
([true true] [false true] [false false] [true true])
(map count ((juxt identity set) (remove #{\space \, \!} "sphinx of the black quartz, judge my vow!")))
(32 26)
(let [m {:a 1, :b 2, :c 44} [ks vs] ((juxt keys vals) m)] [vs ks])
[(1 2 44) (:a :b :c)]
(for [i (range (inc (count [1 2 3 4])))] ((juxt take drop) i [1 2 3 4]))
([() (1 2 3 4)] [(1) (2 3 4)] [(1 2) (3 4)] [(1 2 3) (4)] [(1 2 3 4) ()])
(map second (take 3 (drop 1 (iterate (fn [[n d]] ((juxt quot rem) n 5)) [85 0]))))
(0 2 3)
(map (juxt #(% 1) #(% 3)) [[1 2 3 4 5] [:a :b :c :d :e]])
([2 4] [:b :d])
(map (apply juxt [:a :b :c]) [{:a 0, :b 1, :c 2} {:a 1, :c 3, :d 4}])
([0 1 2] [1 nil 3])
((apply juxt (map (partial partial apply) [+ -])) ((reduce (partial partial reduce) (repeat 1 partial)) [1 2 3]))
[6 -4]
(apply format "foo %s bar %s baz %s" ((juxt :foo :bar :baz) {:foo 1, :bar "a", :baz "hi"}))
"foo 1 bar a baz hi"
(map (comp (partial apply hash-map) (juxt :pos (comp vector :step))) [{:step 1, :pos :s1} {:step 2, :pos :s2}])
({:s1 [1]} {:s2 [2]})
(let [s [1 5 4 3 2 6 7]] ((comp (partial apply map max) (juxt identity rest)) s))
(5 5 4 3 6 7)
((juxt keys vals) {:a [34 56 7], :b [21 87 999], :c [3], :d [2 4], :s [4]})
[(:a :b :c :d :s) ([34 56 7] [21 87 999] [3] [2 4] [4])]
(every? #(apply (fn [x y] (and x y)) ((juxt string? empty?) %)) (list "" '(a b)))
false
(map (juxt sequential? associative?) [(cons 1 nil) (cons 1 '(2 3)) [4 5] {6 7} #{8}])
([true false] [true false] [true true] [false true] [false false])
(#(some (partial = 1) ((apply juxt [:x :y :z :a]) %)) {:a 1, :b 2, :c 3})
true
(let [m (hash-map :a 1 :b 2) f (juxt type identity)] (f (into (empty m) (map identity m))))
[clojure.lang.PersistentHashMap {:a 1, :b 2}]
((juxt #(take-nth 2 %) #(take-nth 2 (next %))) '(1 + 2 + 3 + 4))
[(1 2 3 4) (+ + +)]
((juxt keys vals) {:a [4], :b [21 87 999], :c [3], :d [2 4], :s [34 56 7]})
[(:s :b :c :d :a) ([34 56 7] [21 87 999] [3] [2 4] [4])]
((fn [fk & ms] (into {} (map (juxt fk identity) ms))) :id {:a 2, :id 1} {:b 4, :id 5})
{1 {:a 2, :id 1}, 5 {:b 4, :id 5}}
(map (partial apply (juxt min max)) (apply map vector [[0 1] [2 3] [5 -1] [4 6] [-2 3]]))
([-2 5] [-1 6])
((partial (comp seq reduce) (comp (partial apply conj) (juxt first (comp (partial + 1) second)) list) []) (range 10))
(1 2 3 4 5 6 7 8 9 10)
(let [m {:a 1, :b 2, :c 3}] (into (empty m) (map (juxt key (comp inc val)) m)))
{:a 2, :b 3, :c 4}
((apply juxt [:a :b :c :d #(get % :e :baz)]) {:a 1, :b 2, :c 3, :d 4})
[1 2 3 4 :baz]
(let [num 20 div -6 [a b] ((juxt quot mod) num div)] (= (+ (* a div) b) num))
false
(map (juxt identity true? false? boolean #(if % :then :else)) [0 5 {} [] "foo" :bar 'baz true false nil])
([0 false false true :then] [5 false false true :then] [{} false false true :then] [[] false false true :then] ["foo" false false true :then] [:bar false false true :then] [baz false false true :then] [true true false true :then] [false false true false :else] [nil false false false :else])
(apply concat ((juxt take-while (comp rest drop-while)) #(not= 4 %) [1 2 3 4 5 6 7 8 9]))
(1 2 3 5 6 7 8 9)
(defmacro defn' [name arglist & body] `(defn ~name ~arglist (let [~'&args ~(into {} (map (juxt keyword identity) arglist))] ~@body)))
#'user/defn'
((juxt keys vals) (hash-map :s [34 56 7] :b [21 87 999] :c [3] :d [2 4] :a [4]))
[(:s :c :b :d :a) ([34 56 7] [3] [21 87 999] [2 4] [4])]
(let [num 20 div -6 [a b] ((juxt quot rem) num div)] (= (+ (* a div) b) num))
true
(let [range-incl (fn [a b] (apply range (map + ((juxt min max) a b) [0 1])))] (range-incl 11 -3))
(-3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11)
(let [f #(do (pr %) %)] (map second (sort-by first (map (juxt f identity) ['5 4 3 2 1]))))
(1 2 3 4 5)
"54321"
((comp (partial every? true?) (juxt (comp (partial reduce =) (partial map type)) (partial apply =)) list) [1 2] [1 3])
false
(map (comp (juxt (partial every? identity) (comp not (partial some nil?))) vals) [{:a nil, :b false} {:a "hi", :b false}])
([false false] [false true])
(let [m {:a 1, :b 2, :c 3}] (into (empty m) (map (juxt key (comp (partial * 10) val)) m)))
{:a 10, :b 20, :c 30}
(#(some (partial = %2) ((apply juxt %3) %)) {:a 1, :b 2, :c 3} 1 [:x :y :z :a])
true
((comp (partial every? true?) (juxt (comp (partial reduce =) (partial map type)) (partial apply =)) list) [1 2] [1 2])
true
(#(map (apply juxt %&) (apply clojure.set/intersection (map (comp set keys) %&))) {:a 1, :c 6} {:b 2, :c 3})
([6 3])
((comp (partial apply map vector) (juxt identity (comp reverse (partial take-while first) (partial iterate pop) pop))) [:a :b :c :d])
([:a [:a]] [:b [:a :b]] [:c [:a :b :c]])
(defmacro defn' [name arglist & body] `(defn ~name ~arglist (let [&args ~(into {} (map (juxt keyword identity) arglist))] ~@body)))
#'user/defn'
(sort-by (juxt :foo :bar) #{{:foo 2, :bar 11} {:bar 99, :foo 1} {:bar 55, :foo 2} {:foo 1, :bar 77}})
({:bar 77, :foo 1} {:bar 99, :foo 1} {:bar 11, :foo 2} {:bar 55, :foo 2})
(sort-by (juxt (comp count :key) :otherkey) [{:key '(1 2 3 4), :otherkey 10} {:key '(1 2 3), :otherkey 12}])
({:key (1 2 3), :otherkey 12} {:key (1 2 3 4), :otherkey 10})
(sort-by (juxt :otherkey (comp count :key)) [{:key '(1 2 3 4), :otherkey 10} {:key '(1 2 3), :otherkey 12}])
({:key (1 2 3 4), :otherkey 10} {:key (1 2 3), :otherkey 12})
(map (comp (partial apply hash-map) (juxt :k :v)) [{:k 1, :v 2} {:k 3, :v 4} {:k 5, :v 6}])
({1 2} {3 4} {5 6})
((juxt (partial take-nth 2) (comp (partial take-nth 2) rest)) [1 '+ 2 '* 3 '+ 4 '/ 5 '+ 6])
[(1 2 3 4 5 6) (+ * + / +)]
(let [pop-peek (juxt pop peek) stack [1 2] [stack arg1] (pop-peek stack) [stack arg2] (pop-peek stack)] (conj stack (+ arg1 arg2)))
[3]
(merge-with clojure.set/union {15 #{5 10}, 25 #{5}} (into {} (map (juxt #(+ 5 %) hash-set) #{10 20 30})))
{15 #{5 10}, 25 #{5 20}, 35 #{30}}
((comp (partial every? true?) (juxt (comp (partial reduce =) (partial map type)) (partial apply =)) list) [1 2] '(1 2))
false
((fn [m1 m2] (apply = (map (juxt m1 m2) (keys m1)))) {:bar 6, :foo 2} {:bam 23, :bar 6, :foo 2})
false