(let [[a b & {:keys [c d]}] [1 2 :e :e :d :d :c :c]] [a b c d])
[1 2 :c :d]
(macroexpand '(let [m {:a 1, :b 2, :d 4} {:keys [a b c]} m] [a b c]))
(let [m {:a 1, :b 2, :d 4} {:keys [a b c]} m] [a b c])
(let [base [1 2 3 5 6 8]] (reduce (fn [stack [a b]] (if (= (- a b) -1) (update stack (dec (count stack)) conj a) (conj (update stack (dec (count stack)) conj a) [b]))) [[]] (partition 2 1 base)))
[[1 2 3] [5 5 6] [8]]
(with-in-str "(def a 1) (inc a)" (doall (take-while (complement #{::done}) (repeatedly #(read *in* false ::done)))))
((def a 1) (inc a))
(let [a (atom nil)] [(first (filter #(< 31 %) (map (fn [x] (reset! a x) x) (range)))) @a])
[32 32]
(let [num 20 div -6 [a b] ((juxt quot mod) num div)] (= (+ (* a div) b) num))
false
(let [k :a] (let [[a b c] (k {:a ['foo 'bar 'baz], :b [2 3 4]})] [a b c]))
[foo bar baz]
(let [a {:x 10, :y {:z 20}}] (let [{x :x, y :y, {z :z} :y} a] [x y z]))
[10 {:z 20} 20]
(let [a (atom 0) action (delay (swap! a inc)) f #(force action)] [(f) (f) (f)])
[1 1 1]
((fn [a b & {c :name, d :age, :or {d 10}}] [a b c d]) 1 2 :name "steve")
[1 2 "steve" 10]
(reduce (fn [acc [a b]] (clojure.string/replace acc a b)) (.toLowerCase "Test ?%¥") [[#" " "_"] [#"\?" "_"] [#"\?" "\\"]])
"test__%¥"
(let [a (sorted-map :a 1 :b 2 :c 3) k (keys a)] (last (take-while #(not= % :c) k)))
:b
(let [{:keys [a], :syms [b], :strs [c], :as foo} {:a 1, 'b 2, "c" 3}] [a b c foo])
[1 2 3 {:a 1, b 2, "c" 3}]
(map (fn [a b c d] (a b c d)) (list list list) [1 1] [2 2] [3 3])
((1 2 3) (1 2 3))
(let [num 20 div -6 [a b] ((juxt quot rem) num div)] (= (+ (* a div) b) num))
true
(let [[a b] (split-with #(>= 50 %) [10 20 30 35 40 50 60])] (concat [(last a)] b))
(50 60)
(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 [xs (range 10)] (map (fn [a b] a) xs (take-while #(< % 10) (reductions + 0 xs))))
(0 1 2 3 4)
(let [{:keys #{a b c d}} {:a 1, :b 2, :c 3, :d 4}] [a b c d])
[1 2 3 4]
(let [{:keys [a b c], :as m} {:a 1, :b 2, :c 3, :d 4}] [a b c m])
[1 2 3 {:a 1, :b 2, :c 3, :d 4}]
(reductions (fn [prev [a b]] (+ (/ prev 10.0) a b)) 0 (map list (range 5) (range 5 10)))
(0 5.0 7.5 9.75 11.975 14.1975)
(defn make-toggler [f1 f2 & args] (let [a (atom false)] (fn [] (apply (if (swap! a not) f1 f2) args))))
#'user/make-toggler
(let [f (fn [a b & {:keys [c d]}] [:my-args a b c d])] (f 1 2 :d 5))
[:my-args 1 2 nil 5]
(let [[a b] (split-with #(not= 3 %) [1 2 3 3 45 3 6])] (concat a (rest b)))
(1 2 3 45 3 6)
(let [a (atom nil)] [(first (filter #(< 30 %) (map (fn [x] (reset! a x) x) (range)))) @a])
[31 31]
(let [[a b :as x] [1 2]] b)
2
(-> '(let [a 1]) second first meta)
nil
((fn ([a] 1) ([b c] 2)) :one-arg :another-arg)
2
(map-indexed vector '[a b c d e])
([0 a] [1 b] [2 c] [3 d] [4 e])
(def a [[1] [1 2] [1 2 3]])
#'user/a
(some #{'e} '[a b c d])
nil
(pr-str '[1 2 (a :b #{c})])
"[1 2 ^{:line 1, :column 15} (a :b #{c})]"
(ns a (:require [clojure.string :as str :refer [replace]]))
nil
(clojure.core/defrecord n [a b c d e ...])
#'user/n
(apply map list '((a b) (1 2)))
((a 1) (b 2))
(macroexpand '(f my-func a b c d))
(f my-func a b c d)
(partition-all 2 '(a 1 b 2 c))
((a 1) (b 2) (c))
(partition 2 '[a 1 b 2 c])
((a 1) (b 2))
(for [x '(a b c)] [:record x])
([:record a] [:record b] [:record c])
(defmacro foo [a] `(bar (amacro baz ...)))
#'user/foo
(let [a (range 3)] `(:foo ~@a :bar))
(:foo 0 1 2 :bar)
(str "two hashes need a paren after them")
"two hashes need a paren after them"
(re-matches #"[a[b]c]" "]")
nil
(map #(quote %) '(a b c))
(%1 %1 %1)
(defprotocol AProtocol [x] (foo [a x y] ...))
{:methods #{#object [clojure.lang.MultiFn 0x55fcb7bc "clojure.lang.MultiFn@55fcb7bc"] #object [clojure.lang.MultiFn 0x5b3b42ab "clojure.lang.MultiFn@5b3b42ab"]}, :name user/AProtocol, :ns #object [sci.impl.vars.SciNamespace 0x37a47b18 "user"], :sigs {:foo {:arglists ([a x y] ...), :doc nil, :name foo}, :x {:arglists nil, :doc nil, :name x}}}
(def a (drop 1 (map println (range 10))))
#'user/a
(defprotocol Doubles (^long a [_]) (^long b [_]))
{:methods #{#object [clojure.lang.MultiFn 0x67902607 "clojure.lang.MultiFn@67902607"] #object [clojure.lang.MultiFn 0x6957d485 "clojure.lang.MultiFn@6957d485"]}, :name user/Doubles, :ns #object [sci.impl.vars.SciNamespace 0x37a47b18 "user"], :sigs {:a {:arglists ([_]), :doc nil, :name a}, :b {:arglists ([_]), :doc nil, :name b}}}
(concat '(a b c) (when true ['x]))
(a b c x)
(let [input ^{:foo :bar} {:a 1}] (let [{a :a} input {foo :foo} (meta input)] (str foo \: a)))
":bar:1"
(reduce (fn [a {:keys [id], :as v}] (assoc a id v)) {} [{:id 1, :a :b} {:id 2, :b :a}])
{1 {:a :b, :id 1}, 2 {:b :a, :id 2}}