(map #(-> (+ (+ 1 %) 5)) [1 2 3])
(7 8 9)
(seq (-> "a b c" .toUpperCase (.replace "C" "X") (.split " ")))
("A" "B" "X")
(-> [{:a 0, :b 1} {:a 1, :b 2}] ((partial map :a)))
(0 1)
(macroexpand-1 '(-> (fn [a] (+ a a)) (fn [f] (f 1))))
(fn (fn [a] (+ a a)) [f] (f 1))
(-> " foo BAR baz_quux" .toLowerCase clojure.string/trim (clojure.string/replace #"(\s+|-|_)" "-"))
"foo-bar-baz-quux"
(-> nil (#(and % (.getBytes 5))) (#(and % (count %))))
nil
(-> ["aaaaa" "bbbbbb" "account"] ((fn [arg] (map #(re-matches #".*ccoun.*" %) arg))))
(nil nil "account")
(-> {:foo 12, :bar 14} (assoc :baz 8) (update :bar * 3))
{:bar 42, :baz 8, :foo 12}
(-> "ab" (#(and % (.getBytes %))) (#(and % (count %))))
2
(defn java-random [seed] (-> seed (unchecked-add 0x5deece66d) (unchecked-multiply 0x5deece66d) (bit-shift-right 16) (unchecked-int)))
#'user/java-random
(filter (fn [me] (= (-> (second me) meta :added) "1.4")) (ns-publics 'clojure.core))
()
(into [] (-> "a b c" .toUpperCase (.replace "C" "X") (.split " ")))
["A" "B" "X"]
(-> "<h1>test</h1>" str (.replace "&" "&") (.replace "<" "<") (.replace ">" ">"))
"<h1>test</h1>"
(defmacro ->* [& args] `(-> ~(last args) ~@(butlast args)))
#'user/->*
(defmacro -< [e & forms] (for [f forms] `(-> ~e ~@f)))
#'user/-<
(-> [2 5 4 1 3 6] reverse rest sort (nth 4))
5
(defmacro cond->-> [x & pairs] (if-let [[c form & more] (seq pairs)] `(let [x# ~x] (cond->-> (if (-> x# ~c) (-> x# ~form) x#) ~@more)) x))
#'user/cond->->
(map #(-> % :name (if "named!" "unnamed!")) [{:name "bob"} {:age 23}])
("named!" "unnamed!")
(-> 10 (* 2) (as-> x (if (even? x) x (inc x))))
20
(defn magic-> [fns] (fn [x] (reduce #(-> %1 %2) x fns)))
#'user/magic->
(-> 42 ((apply comp (repeat 10000 atom))) ((apply comp (repeat 10000 deref))))
42
(let [a-fn (fn [x] (map inc x))] (-> [1 2 3] a-fn))
(2 3 4)
(-> [{:a 0, :b 1} {:a 1, :b 2}] (->> (map :a)))
(0 1)
(-> '(do (n) (^{1 2} n)) macroexpand last first meta)
{1 2}
(defn wrap-components [some-component handler] (fn [req] (-> req (assoc ::component some-component) (handler))))
#'user/wrap-components
(-> "a b c" .toUpperCase (.replace "C" "X") (.split " ") seq)
("A" "B" "X")
(-> [1 2] (as-> [x y] [(inc y) (dec x)] [y x]))
[0 3]
(defn unique? [s x] (-> (get (group-by identity s) x) next nil?))
#'user/unique?
(-> {:foo 12, :bar 14} (assoc-in [:baz] 8) (update-in [:bar] * 3))
{:bar 42, :baz 8, :foo 12}
(defmacro unchecked-phase-fn [argvec & forms] `(fn [session# ~@argvec] (-> session# ~@forms)))
#'user/unchecked-phase-fn
(-> (update-in {} [:first] (fnil inc 0)) (update-in [:second] (fnil conj []) :value))
{:first 1, :second [:value]}
(macroexpand '(-> 1 #(* 2 %) #(+ 3 %)))
(fn* (fn* 1 [%1] (* 2 %1)) [%1] (+ 3 %1))
(defmacro run-n-times [initial fun times] `(-> ~initial ~@(repeat times fun)))
#'user/run-n-times
(-> "{:db {:pass \"secret\", :user \"bob\"}}" read-string (get-in [:db :pass]))
"secret"
(-> {:foo 12, :bar 14} (assoc :baz 8) (update-in [:bar] * 3))
{:bar 42, :baz 8, :foo 12}
(macroexpand '(-> [5 4 3 2 1] (drop 2) (take 3)))
(take (drop [5 4 3 2 1] 2) 3)
(-> {:a 1, :b 2} (dissoc :a) (doto println) (update-in [:b] inc))
{:b 3}
"{:b 2}\n"
(-> 1 (doto prn) inc (doto prn) (* 10) (doto prn) dec)
19
"1\n2\n20\n"
(update-in {:x [1 2 3 4]} [:x] #(-> % last vector))
{:x [4]}
(-> (binding [*print-meta* true] (pr-str (with-meta [1 2 3] {:doc "ohai"}))) read-string meta)
{:doc "ohai"}
(let [x [1 2 3 4 5]] (nth x (-> x count rand-int)))
1
(defn java-random [^long seed] (-> seed (unchecked-add 0x5deece66d) (unchecked-multiply 0x5deece66d) (bit-shift-right 16) (unchecked-int)))
#'user/java-random
(binding [*print-dup* true] (-> '(defrecord Foo [^int a b c]) macroexpand-1 pr-str))
"(clojure.core/defrecord Foo [^int a b c])"
(let [me {:rollodex {:contacts {:mom "Anna", :dad :dead}}}] (-> me :rollodex :contacts :mom))
"Anna"
(map #(-> [1 (inc %) 2 (dec %) 3]) [5 10 15])
([1 6 2 4 3] [1 11 2 9 3] [1 16 2 14 3])
(defn wrap-quotes [x] #{(-> ["\u0022" x] cycle flatten (partial take 3) str)})
#'user/wrap-quotes
([0 1 2 #{3 4 5}] (-> {:a {:b 3}} :a :b))
#{3 4 5}
(let [*modulus* 3] (take 3 (iterate #(-> % (inc) (mod *modulus*)) 1)))
(1 2 0)
(defmacro test [& a] `(fn [d#] (-> d# ~@(map eval a))))
#'user/test
(-> (apply (fn [& args] args) 1 2 3 4 (range 5)) str)
"(1 2 3 4 0 1 2 3 4)"