(let [x [1 2 3] s (seq x)] (identical? (next s) (next s)))
false(let [a 1 b (inc a) c (+ a b) c (inc c)] c)
4(let [{:strs [a b c]} {:a 0, :b 1, :c 2}] [a b c])
[nil nil nil]
(let [hello (fn [{:keys [name], :or {:name "unknown person"}}] (println "hello, " name))] (hello {}))
nil"hello, nil\n"(let [myfun (fn [& args] (apply + args))] (myfun 1 2 3 4 5))
15(take 20 (let [a (iterate inc 1)] (for [x a y a] [x y])))
([1 1] [1 2] [1 3] [1 4] [1 5] [1 6] [1 7] [1 8] [1 9] [1 10] [1 11] [1 12] [1 13] [1 14] [1 15] [1 16] [1 17] [1 18] [1 19] [1 20])
(let [{:keys [x], :syms [x], :strs [x]} {:x :keyword, "x" :string, 'x :symbol}] x)
:string(let [midpoint (fn [coll] (let [idx (quot (count coll) 2)] [(vec (take idx coll)) (nth coll idx) (vec (drop (inc idx) coll))]))] (midpoint [1 2 3 4 5 6 7]))
[[1 2 3] 4 [5 6 7]]
(let [[n & options] '[namespace :only [functions]]] (assoc (apply hash-map options) :name n))
{:name namespace, :only [functions]}
(let [m (into (hash-map) (sorted-map :a 1 :b 2 :c 3))] [(class m) m])
[clojure.lang.PersistentArrayMap {:a 1, :b 2, :c 3}]
(let [{:as charnock, ohai ":ohai", whitefield ":whitefield"} {":ohai" :a, ":whitefield" :b}] [charnock ohai whitefield])
[{":ohai" :a, ":whitefield" :b} :a :b]
(defmacro foo [a] (let [bar (+ a 2)] `(fn [bar] (* bar 3))))
#'user/foo
(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(let [f (fn [a] (+ a 5)) g (fnil f 10)] (g nil))
15(let [adder (fn [x] #(+ x %))] (map (adder 2) [1 2 3]))
(3 4 5)
(let [x [1 2 3 4]] (conj (subvec x 0 3) (subvec x 3)))
[1 2 3 [4]]
(let [s "foo bar"] (str (apply str (repeat (- 20 (count s)) \space)) s))
" foo bar"(let [{:keys [a b c]} {:a 0, :b 1, :c 2}] [a b c])
[0 1 2]
(let [z 4 a-seq [1 2 3]] (reduce #(conj %1 %2 z) [] a-seq))
[1 4 2 4 3 4]
(let [v (atom [])] (dotimes [n 100000] (swap! v conj n)) (apply max (shuffle @v)))
99999(defn palindrome? [num] (let [s (str num)] (= s (->> s reverse (apply str)))))
#'user/palindrome?
(defn dfn [f & args] (let [d (delay (apply f args))] #(deref d)))
#'user/dfn
(let [x 1 y 2 z [3 4 5]] `(~x ~y ~z ~@z))
(1 2 [3 4 5] 3 4 5)
(let [vec [:a :b :c]] (first (filter (comp #{:c} vec) (range (count vec)))))
2(let [vec [0 1 2 3 4 5]] (conj (pop vec) (inc (peek vec))))
[0 1 2 3 4 6]
(macroexpand `(let [[& {:keys [b a], :or {b @a}}] [:a (atom 5)]] b))
(clojure.core/let [[& {:keys [user/b user/a], :or {user/b (clojure.core/deref user/a)}}] [:a (clojure.core/atom 5)]] user/b)
(let [{{{[one two three] :c} :b} :a} {:a {:b {:c [41 42 43]}}}] two)
42(defmacro defn-with-expr [expr args & body] (let [val expr] `(defn ~val ~args ~@body)))
#'user/defn-with-expr
(let [a (fn [& {:keys [a b]}] [a b])] (a :a 1 :b 2))
[1 2]
(defmacro defspecialfn [& body] `(let [{:keys ~'[your keys here]} (deref *the-global-map*)] ~@body))
#'user/defspecialfn
(let [[a b c :as d] [1 2 3 4]] [a b c d])
[1 2 3 [1 2 3 4]]
(let [a {:x 1} b (assoc a :x -10)] (println a) (println b))
nil"{:x 1}\n{:x -10}\n"(let [x 5 form '`(x ~x) evaled-form `(x ~x)] [form evaled-form])
[(clojure.core/sequence (clojure.core/seq (clojure.core/concat (clojure.core/list (quote user/x)) (clojure.core/list x)))) (user/x 5)]
(let [f #(< % 5) xs (shuffle (range 15))] (partition-by f xs))
((8 12 7) (4) (5 11 10 9) (1) (13) (2) (14) (3 0) (6))
(let [x [1 2 4 5]] (concat (take 2 x) [3] (drop 2 x)))
(1 2 3 4 5)
(let [a {:a 1, :b 2} b (with-meta a {:blah true})] (= a b))
true(let [m {:foo 4}] (identical? m (-> m (assoc :foo 5) (assoc :foo 4))))
false(defn test1 [n] (let [x 10] (list (fn [] n) (fn [i] (+ i x)))))
#'user/test1
(let [m {:x 1, :y 2}] (into {} (for [[k v] m] [k (inc v)])))
{:x 2, :y 3}
(let [[a b :as m] [1 2 3 4 5 6]] [a b m])
[1 2 [1 2 3 4 5 6]]
(let [a (atom nil)] (reset! a (fn [] (reset! a 10))) (@a) @a)
10(defn doubler [f] (let [f f] (fn [& args] (* 2 (apply f args)))))
#'user/doubler
(let [foo-seq (repeatedly #(do (println "lazy-seq evaluated"))) bar (rest foo-seq)] (take 1 bar))
(nil)
"lazy-seq evaluated\nlazy-seq evaluated\n"(let [a {:a []} c [{:a 2} {:a 3}]] (apply merge-with conj a c))
{:a [2 3]}
(let [ks '(a b c)] (zipmap ks (map #(str % "val") ks)))
{a "aval", b "bval", c "cval"}
(let [string "hello world" len 5] (apply str (take (- (count string) len) string)))
"hello "(let [result (take-while true? [false true true false true])] (if (empty? result) nil result))
nil(let [L (with-meta (map identity '(a b)) {:foo :bar})] (meta (conj L 'c)))
nil(defmacro multi-if [test & args] (let [chunks (partition-by #{:then :else} args)] (let [chunkmap (apply hash-map (map first chunks))] (list 'cond 'test (list 'do (:then chunkmap))) :else (list 'do (:else chunkmap)))))
#'user/multi-if

