(#(do (-> (last %&) (list (reverse (pop (reverse %&)))))) 1 2 3)
(3 (1 2))
(macroexpand '(-> (one two three) (four five six) (seven eight nine) ten))
(ten (seven (four (one two three) five six) eight nine))
(-> (apply (fn [& args] args) 1 2 3 4 (range 5)) pr-str)
"(1 2 3 4 0 1 2 3 4)"
(-> '(1 2 3 4) (#(map %2 %1) #(inc %1)))
(2 3 4 5)
(defmacro thread-splicing [e & forms] (vec (for [f forms] `(-> ~e ~@f))))
#'user/thread-splicing
(-> [1 2 3] (as-> xs (map inc xs) (do (println xs) xs)))
(2 3 4)
"(2 3 4)\n"
(macroexpand-1 `(-> 2 (partition 2 '(+ 4 * 3 - 7))))
(clojure.core/partition 2 2 (quote (clojure.core/+ 4 clojure.core/* 3 clojure.core/- 7)))
(into {} (for [x [0 1 2 3 4]] [(-> x str keyword) 0]))
{:0 0, :1 0, :2 0, :3 0, :4 0}
(map #(-> % (min 0) (max 100)) [-5 0 50 100 105])
(100 100 100 100 100)
(-> (list 1) (with-meta {:x 1}) (conj 2) (with-meta {:y 2}) next meta)
{:x 1}
(let [a nil] (-> 5 ((fn [x] (if a (+ x a) x)))))
5
(-> [1 2 3 4] (assoc (rand-int 4) 'foo) (assoc (rand-int 4) 'bar))
[1 foo bar 4]
(-> {:a 1, :b 2, :c 3, :d 4} (select-keys [:a :b]) vals)
(1 2)
(-> (some #{-1 1} (map compare [1 2] [1 2])) (or 0))
0
(filter #(-> % (rem 3) zero?) (take 100 (repeatedly #(rand-int 10))))
(9 3 3 6 6 6 6 9 3 9 3 3 6 3 0 6 6 0 9 3 0 9 0 0 6 3 3 3 0 0 6 6 0 3 0 3 9 3 6 3 0 0)
(-> [{:a 0, :b 1} {:a 1, :b 2}] (#(map :a %)))
(0 1)
(macroexpand '(-> "test" #(str "you can't do that it seems:" %1)))
(fn* "test" [%1] (str "you can't do that it seems:" %1))
(#(do (flatten (-> (last %&) (list (reverse (rest (reverse %&))))))) 'a 'b 'c)
(c a b)
(def x (-> {:a 1, :b 2, :c 3} (dissoc :b) (assoc :d 42)))
#'user/x
(-> [[1 2 3] [4 5 6] [7 8 9]] (get 1) (get 1))
5
(into {} (for [x [0 1 2 3 4]] [#(-> % str keyword) 0]))
{#object[sci.impl.fns$fun$arity_1__26688 0x10938950 "sci.impl.fns$fun$arity_1__26688@10938950"] 0, #object[sci.impl.fns$fun$arity_1__26688 0x1e547532 "sci.impl.fns$fun$arity_1__26688@1e547532"] 0, #object[sci.impl.fns$fun$arity_1__26688 0x1a6be220 "sci.impl.fns$fun$arity_1__26688@1a6be220"] 0, #object[sci.impl.fns$fun$arity_1__26688 0x5f697f09 "sci.impl.fns$fun$arity_1__26688@5f697f09"] 0, #object...
(defn rename-key [m oldk newk] (-> m (dissoc oldk) (assoc newk (m oldk))))
#'user/rename-key
(letfn [(digits [n] (map #(-> % str Integer/parseInt) (str n)))] (digits 1234))
(1 2 3 4)
(map println (-> "a b c" .toUpperCase (.replace "C" "X") (.split " ")))
(nil nil nil)
"A\nB\nX\n"
(macroexpand '(def app (-> routes wrap-params wrap-db (#(wrap-resource % "static")) wrap-server)))
(def app (-> routes wrap-params wrap-db ((fn* [%1] (wrap-resource %1 "static"))) wrap-server))
(-> [1 2 3 4] (subvec 1 (dec (count [1 2 3 4]))))
[2 3]
(-> (repeat 4 0) (into [1 2 3 4]) (into (repeat 4 0)))
(0 0 0 0 4 3 2 1 0 0 0 0)
(-> * (#(%)) inc (as-> x (do (def foo x) x)) inc)
3
(defn wrap-quotes [x] (-> ["\u0022" x] cycle flatten (partial take 3) str set))
#'user/wrap-quotes
(map #(-> % (max 0) (min 100)) [-5 0 50 100 105])
(0 0 50 100 100)
(defmacro ->is [val & exprs] `(let [x# ~val] (is (-> x# ~@exprs)) x#))
#'user/->is
(let [coll '([:!f (fn [x] (inc x)) :data])] (fn? (-> coll first second)))
false
((-> fact (fn [n] (if (zero? n) 1 (* (fact (dec n)) n)))) 5)
120
(def very-lazy (-> (iterate #(do (print \.) (inc %)) 1) rest rest rest))
#'user/very-lazy
".."
(-> {:a 1, :b {:x "hello", :y "goodbye"}, :c 3} (assoc-in [:b :x] "test"))
{:a 1, :b {:x "test", :y "goodbye"}, :c 3}
(let [m {:foo 4}] (identical? m (-> m (assoc :foo 5) (assoc :foo 4))))
false
(defmacro heck-> ([x] x) ([x form] `(-> ~x ~form)) ([x form1 & more] `(let [x1# ~x x2# (-> x1# ~form1)] (heck-> (if (nil? x2#) x1# x2#) ~@more))))
#'user/heck->
(-> (for [x (take 100 (iterate inc 0))] (do (println x) x)) seq boolean)
true
"0\n"
(defmacro sym-meta "Despite Bronsa" [sym] (-> &env (find sym) (some-> key) (or sym) meta))
#'user/sym-meta
(-> 321 Integer/toString ((partial repeat 2)) ((juxt first (comp reverse second))) ((partial apply concat)))
(\3 \2 \1 \1 \2 \3)
(clojure.walk/postwalk (juxt identity meta) {:a 1, :b (-> '(f x) (with-meta {:m 1}))})
[{[[:a nil] [1 nil]] nil, [[:b nil] [([f nil] [x nil]) nil]] nil} nil]
(-> [:a :b :c] (#(concat % [:x :y])) (#(concat [:f :g] %)))
(:f :g :a :b :c :x :y)
(let [m {:a (into-array [1])}] (aset (:a m) 0 99) (-> m :a first))
99
((-> $ #(* % (({(*) {(+) (*)}} % $) (- % (*))))) 10)
3628800
(-> (sorted-set-by #(< (%1 1) (%2 1))) (conj [1 3]) (conj [2 3]))
#{[1 3]}
(-> 10 (* 2) (+ 1) (as-> x (if (even? x) x (inc x))))
22
(filter #(-> % :name #{"Bar" "boo"}) [{:name "Bla"} {:name "Foo"} {:name "boo"}])
({:name "boo"})
(meta (-> (binding [*print-meta* true] (pr-str (with-meta [1 2 3] {:doc "ohai"}))) read-string meta))
nil
(-> (vec (repeat 4 0)) (into [1 2 3 4]) (into (repeat 4 0)))
[0 0 0 0 1 2 3 4 0 0 0 0]
(defmacro -< [e & forms] (apply vector (for [f forms] `(-> ~e ~@f))))
#'user/-<