(let [a 1 b 2] (+ a a a b b))
7(defmacro aif [x y] `(let [~'it ~x] (if ~'it ~y)))
#'user/aif
(let [a 0xf000] (if (< a 0x8000) a (- a 0x10000)))
-4096(let [a 0 b 1] (+ a a a b b))
2(let [coll [:a :b :c]] (partition 2 1 (cons :prefix coll)))
((:prefix :a) (:a :b) (:b :c))
(let [s #{:a :b :c :d}] [(first s) (rest s)])
[:c (:b :d :a)]
(defn func ([] (func 1)) ([p] (let [p (- p 1)]) p))
#'user/func
(let [a {:a :b, :c :d}] (pr-str (map reverse (into [] a))))
"((:b :a) (:d :c))"(let [{:keys [a b]} {:a 21, :b 2}] (* a b))
42(let [v [1 2 3]] (into {} [[(seq v) 1] [v 2]]))
{(1 2 3) 2}
(defn make-adder [x] (let [y x] (fn [z] (+ y z))))
#'user/make-adder
(let [{:keys [foo bar], :or {foo 1}} {:bar 5}] [foo bar])
[1 5]
(let [foo {:a :b, :c :d}] (zipmap (vals foo) (keys foo)))
{:b :a, :d :c}
(let [[f s] (clojure.string/split "split me" #" " 1)] [f s])
["split me" nil]
(let [a 0 _ (println a) b 1] (* 3 b))
3"0\n"(let [[_ _ :as first-two] '(a b c d)] first-two)
(a b c d)
(let [a 2 _ (println a) b 3] (+ a b))
5"2\n"(let [m {:a "m", :b "m"}] (zipmap (vals m) (keys m)))
{"m" :b}
(let [[[a b] c] [[1 2] 3]] (vector a b c))
[1 2 3]
(let [a {:foo [10 20 30]}] (-> a :foo (nth 1)))
20(let [intrange (range 0 10000)] (doseq [anint intrange] (+ anint anint)))
nil(let [things [[1 2] [3 4]]] (for [[x y] things] y))
(2 4)
(let [start [1 2 3]] (identical? start (pop (conj start 4))))
false(let [x [1 2 3]] [(concat x [4]) (concat x [5])])
[(1 2 3 4) (1 2 3 5)]
(let [[function & args] (list '/ 1 3)] (apply function args))
3(let [{t true, f false} {true 'xs, false 'ys}] [t f])
[xs ys]
(let [foo (fn [x y] (+ x y))] (foo 4 5))
9(let [x [1 2 3] y (into x [2])] [x y])
[[1 2 3] [1 2 3 2]]
(let [exp '(mainreq ctx)] `(with-open [~'ctx (zmq/context 1)] ~exp))
(clojure.core/with-open [ctx (zmq/context 1)] (mainreq ctx))
(let [{foo 1, bar 3} [:a :b :c :d]] [foo bar])
[:b :d]
(let [[f & vs] '(/ 16 8)] `(~f vs))
(/ user/vs)
(let [k 10] (println k) (+ k 1) (+ k 2))
12"10\n"(let [key :foo] ((fn [& {:keys [foo]}] (prn foo)) key 1))
nil"1\n"(defmacro mac [] `(let [x# '(1 2 3)] (first x#)))
#'user/mac
(let [x 10] (filter (fn [item] (< item 10)) (range 30)))
(0 1 2 3 4 5 6 7 8 9)
(let [name 'test] `(defn ~(symbol (str name "?")) [] (...)))
(clojure.core/defn test? [] (user/...))
(let [afn (fn [i] inc i)] (map afn [1 2 3]))
(1 2 3)
(let [a 5 b (* 2 a) a 2] a)
2(let [[f l] (.split "hello.txt" "\\.")] (str f "-timestamp" "." l))
"hello-timestamp.txt"(let [[& {:keys [foo bar]}] [:foo 'a :bar 'b]] [foo bar])
[a b]
(defmacro with-letters [expr] `(let [~@(mapcat (fn [i] (let [sym (-> i char str symbol)] [sym (list 'quote sym)])) (range 97 123))] ~expr))
#'user/with-letters
(let [m (transient (apply hash-map (range 20)))] (dotimes [n 10000] (assoc! m n (inc n))) (let [m' (persistent! m)] [(count m') (get m' 4567)]))
[10000 4568]
(let [x (transient [1 2 3])] (conj! x x) (persistent! x))
[1 2 3 #object [clojure.lang.PersistentVector$TransientVector 0x72a2fc6e "clojure.lang.PersistentVector$TransientVector@72a2fc6e"]]
(let [x 2 y 3 z [x y]] `(1 ~z))
(1 [2 3])
(let [{:syms [k1 k2]} {'k1 1, 'k2 2}] (prn k1 k2))
nil"1 2\n"(let [c [{:name "foo"} {:name "bar"}]] (zipmap (map :name c) c))
{"bar" {:name "bar"}, "foo" {:name "foo"}}
(let [x [1 2 3 4]] (zipmap x (map inc x)))
{1 2, 2 3, 3 4, 4 5}
(let [params '(1 2 3 4 5)] (apply + params))
15(let [{aa :a, bb :b} {:a 1, :b 2}] [aa bb])
[1 2]
(let [ext "xls"] (clojure.string/replace "test.xls" (re-pattern (str "\\." ext "$")) "html"))
"testhtml"

