(map (juxt #(mod (- %1) (- %2)) #(- (mod %1 %2))) [20 20 -20 -20] [6 -6 -6 6])
([-2 -2] [4 4] [2 2] [-4 -4])
(map (comp (partial apply zipmap) (juxt (comp list :pos) (comp list vector :step))) [{:step 1, :pos :s1} {:step 2, :pos :s2}])
({:s1 [1]} {:s2 [2]})
(map (comp (partial apply zipmap) (partial (juxt (comp vector :pos) (comp vector vector :step)))) [{:step 1, :pos :s1} {:step 2, :pos :s2}])
({:s1 [1]} {:s2 [2]})
(let [cpcount #(.codePointCount % 0 (.length %)) a "\ud80c" b "\udc00"] (map (juxt count cpcount) [a b (str a b)]))
([1 1] [1 1] [2 1])
(let [ms [{:id 1, :x 1} {:id 2, :x 2} {:id 1, :x 3}]] (->> ms (map (juxt :id identity)) (into {}) (vals)))
({:id 1, :x 3} {:id 2, :x 2})
(reduce into ((juxt vec #(apply map list %) (comp list (partial map-indexed #(nth %2 %)))) (partition 3 (range 9))))
[(0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8)]
((juxt :a :b :c :d :e :f :g) {:a 0, :b 42, :c 33, :d 666, :e 420, :f false, :g 2})
[0 42 33 666 420 false 2]
(map #(->> % ((apply juxt [:a :b])) (clojure.string/join ",") (format "[%s]")) [{:a 1, :b 2} {:a 5, :b 7}])
("[1,2]" "[5,7]")
(let [m1 {:foo 1, :bar 2, :baz 3} m2 {:foo 4, :bar 5}] (->> (keys m1) (map (juxt identity m2)) (into {})))
{:bar 5, :baz nil, :foo 4}
((comp (partial apply hash-map) (juxt (constantly :a) :a (constantly :inner_a) (comp :inner_a :user))) {:a 2, :b 3, :user {:inner_a 5, :inner_b 9}})
{:a 2, :inner_a 5}
((fn [m1 m2] (every? (partial apply =) (map (juxt m1 m2) (keys m1)))) {:bar 6, :foo 2} {:bam 23, :bar 6, :foo 2})
true
(map (juxt seq? sequential?) [[1 2 3] {:a 1, :b 2} '(1 2 3) (seq [1 2 3]) (lazy-seq [1 2 3])])
([false true] [false false] [true true] [true true] [true true])
(defn -:> [v & pairs] (let [pairs (partition 2 pairs) keys (map first pairs) fns (map second pairs)] (zipmap keys ((apply juxt fns) v))))
#'user/-:>
(let [g (->> (gensym) str (re-find #"\d+") (#(Integer/parseInt %)) inc inc inc (str "G__") symbol)] ((juxt identity eval) `(let [~g (gensym)] ~g)))
[(clojure.core/let [G__1218876 (clojure.core/gensym)] G__1218876) G__1218876]
(with-local-vars [a 0 b 1] (dotimes [_ 10] (var-set a (+ @a @b)) (var-set b (+ @a @b))) (mapv (juxt identity deref) [a b]))
[[#'G__1243627 6765] [#'G__1243628 10946]]
(map (comp (partial apply hash-map) (juxt key (comp :c val))) {:one {:a 1, :b 2, :c 3}, :two {:a 10, :b 20, :c 30}})
({:one 3} {:two 30})
(let [stack [1 2] pop-peek (juxt pop peek) [stack arg1] (pop-peek stack) [stack arg2] (pop-peek stack)] (conj stack (+ arg1 arg2)))
[3]
(defn -:> [v & pairs] (let [pairs (partition 2 pairs) keys (map first pairs) fns (map second pairs)] (zipmap ((apply juxt fns) v) keys)))
#'user/-:>
(let [v [1 5 3 3 2 4 5 5 4 5 1 2 1 2 3 5]] (map (juxt first count) (partition-by identity v)))
([1 1] [5 1] [3 2] [2 1] [4 1] [5 2] [4 1] [5 1] [1 1] [2 1] [1 1] [2 1] [3 1] [5 1])
(sort-by (juxt :otherkey (comp count :key)) (comp - compare) [{: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})
((juxt #(apply concat (take-nth 2 %)) #(apply concat (take-nth 2 (next %)))) (partition-by odd? [1 2 2 3 4 5 5 7 8 9]))
[(1 3 5 5 7 9) (2 2 4 8)]
((juxt (partial take 3) (comp (partial take 1) (partial drop 3)) (comp (partial take 2) (partial drop 4))) (re-seq #"\w+" "blah blah blah blah blah blah"))
[("blah" "blah" "blah") ("blah") ("blah" "blah")]
(let [f #(if (= % 7) [:hi 6 6] :hi) g inc h inc] (= ((comp f g h) 5) ((juxt f g h) 5)))
true
(->> rand repeatedly (partition 4) (take 20) (map (juxt identity #(apply hash-map %))) (map #(map (comp flatten seq) %)) (map #(apply = %)) set)
#{false true}
((juxt #(reduce concat (take-nth 2 %)) #(reduce concat (take-nth 2 (next %)))) (partition-by odd? [1 2 2 3 4 5 5 7 8 9]))
[(1 3 5 5 7 9) (2 2 4 8)]
(let [v [1 5 3 3 2 4 5 5 4 5 1 2 1 2 3 5]] (map (juxt first count) (vals (group-by identity v))))
([1 3] [5 5] [3 3] [2 3] [4 2])
(apply (fn [a b] (a b)) ((apply juxt (map (fn [length] (comp second #(nth % length))) [27 15])) (filter (comp #{\?} last name first) (seq (ns-map *ns*)))))
false
(apply (fn [a b] (a b)) ((apply juxt (map (fn [length] (comp second #(nth % length))) [27 15])) (filter (comp #{\?} last name first) (seq (ns-map *ns*)))))
false
(into {} (map (juxt first #(let [lvals (rest %1)] (if (= (count lvals) 1) (first lvals) (vec lvals)))) [[:a 1 2 3] [:b 4 5 6] [:c 7]]))
{:a [1 2 3], :b [4 5 6], :c 7}
((comp (juxt :accum :result) reduce) (fn [{:keys [accum result]} x] {:accum (conj accum x), :result (conj result (accum x))}) {:accum #{}, :result []} [:a :b :b :c :d :c])
[#{:a :b :c :d} [nil nil :b nil nil :c]]
(reduce (fn [m [k v]] (update-in m [k] (fnil conj #{}) v)) {15 #{5 10}, 25 #{5}} (map (juxt #(+ 5 %) identity) #{10 20 30}))
{15 #{5 10}, 25 #{5 20}, 35 #{30}}
((juxt (fn [& {:keys [a b], :or {a 10, b 20}, :as more}] [a b more]) (fn [& {:keys [a b], :or [a 10 b 20], :as more}] [a b more])) :a 10)
[[10 20 {:a 10}] [10 nil {:a 10}]]
(let [ord #(quot % 1000)] (apply mapcat (fn [prev sub] (concat (repeat (dec (- (ord (first sub)) (ord (first prev)))) []) [sub])) ((juxt identity rest) (cons [0] (partition-by ord [1 35 456 2005 3045 3987])))))
((1 35 456) [] (2005) (3045 3987))
(apply (juxt max min) (apply map + (partition 20 [2 1 2 2 0 3 0 0 1 -1 1 -1 1 -1 -2 0 -3 0 -2 -3 -1 -3 -3 -2 -2 -2 0 -4 -2 -2])))
[3 -3]
(let [sym (gensym) h #(with-meta % {sym true}) g #(if (-> % meta sym) (constantly %) %) f #(if (fn? %) [(%) (%) (%)] %) x 'foo] (= ((comp f g h) x) ((juxt f g h) x) [x x x]))
true
(let [gross (reify Object (equals [_ x] true)) f #(if (identical? % gross) [gross gross gross] gross) g (constantly gross) h (constantly gross) x 5/19] (= ((comp f g h) x) ((juxt f g h) x) [x x x]))
false