(let [m [1 4 2 7 8 5]] (apply (juxt min max) m))
[1 8]
((comp first (partial nth (iterate (juxt second (partial apply +)) [1 1]))) 6)
13(take 5 (for [i (range)] ((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 (juxt (constantly 1) inc (constantly 2) dec (constantly 3)) [5 10 15])
([1 6 2 4 3] [1 11 2 9 3] [1 16 2 14 3])
(map (comp (partial interleave [1 2 3]) (juxt inc dec)) [5 10 15])
((1 6 2 4) (1 11 2 9) (1 16 2 14))
(into {} (map (juxt :name identity) [{:name "al", :job "mcdonalds"} {:name "joe", :job "president"}]))
{"al" {:job "mcdonalds", :name "al"}, "joe" {:job "president", :name "joe"}}
((juxt (partial map first) (partial map second)) [[1 2] [3 4] [5 6]])
[(1 3 5) (2 4 6)]
((juxt first second) (partition 2 [1 2 3 4 5 6 7 8]))
[(1 2) (3 4)]
(defn build-table' [coll] (map (juxt identity #(filter (partial >= %) coll)) coll))
#'user/build-table'
(into {} (map (juxt key (comp inc val)) {:a 1, :b 2, :c 3}))
{:a 2, :b 3, :c 4}
(let [m ["the" "quick" "brown" "fox"]] (apply (partial (juxt max-key min-key) count) m))
["brown" "fox"]
(sorted-set-by #(compare ((juxt :estimate vec) %1) ((juxt :estimate vec) %2)) {:estimate 8, :val -1} {:estimate 1, :val 42} {:estimate 1, :val 100} {:estimate 2, :val 33})
#{{:estimate 8, :val -1} {:estimate 1, :val 100} {:estimate 2, :val 33} {:estimate 1, :val 42}}
(map (apply juxt [:a :b]) [{:a 1, :b 2} {:a 5, :b 7}])
([1 2] [5 7])
((fn rle [s] (apply str (mapcat (juxt count identity) (partition-by identity s)))) "aaabddcejkkeddddddd")
"3(\\a \\a \\a)1(\\b)2(\\d \\d)1(\\c)1(\\e)1(\\j)2(\\k \\k)1(\\e)7(\\d \\d \\d \\d \\d \\d \\d)"(map (juxt :a :b) [{:a 0, :b 3} {:a 5, :b 42}])
([0 3] [5 42])
(filter (juxt inc dec) [1 2 3 4 5 6 7 8 9])
(1 2 3 4 5 6 7 8 9)
(let [m {:a 1, :b 2, :c 3}] ((apply juxt (keys m)) m))
[1 2 3]
(map second (sort-by first (map (juxt rand identity) [5 4 3 2 1])))
(1 2 4 3 5)
(->> {:a 3, :b 2, :c 1} (sort-by val) (map (juxt identity type)))
([[:c 1] clojure.lang.MapEntry] [[:b 2] clojure.lang.MapEntry] [[:a 3] clojure.lang.MapEntry])
((juxt #(filter even? %) #(filter odd? %)) [1 2 3 4])
[(2 4) (1 3)]
(let [m [1 4 2 7 8 5]] ((juxt first last) (sort m)))
[1 8]
(let [x 1] (meta (with-meta [1 x 3] {:foo x})))
{:foo 1}
(let [{bar :bar, :as stuff} {:bar 1, :foo 2}] stuff)
{:bar 1, :foo 2}
(def ^{:foo 1} v ^{:bar 2} {:a :b})
#'user/v
(assoc (sorted-map-by #(> (val %1) (val %2))) :foo 1)
{:foo 1}
(let [ihaveamap {:foo nil, :bar nil}] (assoc ihaveamap :bar 100))
{:bar 100, :foo nil}
(((fn [x] (fn [& y] x)) 1) :foo :bar :baz)
1(binding [*print-meta* true] (pr-str ^{:foo :bar} [1 2 3]))
"^{:foo :bar} [1 2 3]"(into {} (map vec (partition 2 '(:foo "bar" :baz "spam"))))
{:baz "spam", :foo "bar"}
(-> "^{:foo (I am not eval'd)} {}" read-string meta)
{:foo (I am not eval'd)}
(let [m {:foo 3}] (println (get m (first (keys m)))))
nil"3\n"((fn [& args] (->> args (iterate next) (take-while identity) (filter (comp #{:foo} first)) first second)) 1 2 :foo 3 4 5 6)
3(every? true? (apply map > ((juxt rest seq) [1 3 4 6 7])))
true(some (partial apply =) ((comp (partial apply map list) (juxt identity rest)) "somestring"))
nil(some (partial apply =) ((comp (partial apply map list) (juxt identity rest)) "someestring"))
true(->> {:a 10, :b 20, :c 30} ((juxt :a :b :c :d)) (sort))
(nil 10 20 30)
(defn count-true [input & preds] (->> input ((apply juxt preds)) (filter true?) (count)))
#'user/count-true
(map (juxt not-empty (comp not empty) (comp not empty?)) [nil [] [1 2 3]])
([nil true false] [nil false false] [[1 2 3] false true])
((juxt namespace name) (keyword "well that's cheating, but this keyword / is worse"))
["well that's cheating, but this keyword " " is worse"]
(map (juxt str pr-str) [[1 2 3] ["1" "2" "3"] [\1 \2 \3]])
(["[1 2 3]" "[1 2 3]"] ["[\"1\" \"2\" \"3\"]" "[\"1\" \"2\" \"3\"]"] ["[\\1 \\2 \\3]" "[\\1 \\2 \\3]"])
((comp not empty?) (filter #(= % :baz) [:foo :bar]))
false(map vec {:a #{:foo :bar}, :b #{:baz}})
([:a #{:bar :foo}] [:b #{:baz}])
((partial assoc {:text "flarp"} :id) (-> {:foo 45} vals first))
{:id 45, :text "flarp"}
(meta (-> [2 3] (with-meta {:foo :bar}) (conj 8) (empty)))
{:foo :bar}
(into {} (map vec (partition 2 '(:foo :bar :baz :binz))))
{:baz :binz, :foo :bar}
(into {} (for [[b a] {:foo "foo", :bar "bar"}] [a b]))
{"bar" :bar, "foo" :foo}
(let [x 1] (meta ^{:foo x} [1 x 3]))
{:foo 1}
(let [x (with-meta [] {:foo 3})] (identical? x (with-meta x nil)))
false(macroexpand (quote (macroexpand '(->> [:foo :bar] cycle (take-nth 4)))))
(macroexpand (quote (->> [:foo :bar] cycle (take-nth 4))))
(defn f [l] (->> l (map :foo) (reduce 0 max)))
#'user/f

