(defmacro t [f] `(fn [c#] (let [result# (range c#)] (when ~f (last result#)))))
#'user/t
(let [my-string "foo bar (some s-expression)"] (read-string (str "[" my-string "]")))
[foo bar (some s-expression)]
(let [a '(1 2 3)] (concat (take 1 a) [4] (drop 2 a)))
(1 4 3)
(defmacro foo [[a b c] & ds] (let [f (or (:f c) :g)]))
#'user/foo
(let [test (atom #{:a :b})] (swap! test #(apply disj % @test)) @test)
#{}
(let [{:keys [a b c :a all]} {:a 0, :b 1, :c 2}] all)
nil(let [x (gensym)] `(fn [~x] (. ~(with-meta x {:tag (resolve 'String)}) toString)))
(clojure.core/fn [G__992901] (. G__992901 user/toString))
(let [s [1 5 4 3 2 6 7]] (map max s (rest s)))
(5 5 4 3 6 7)
(let [x (iterate #(do (print "test") (inc %1)) 1)] (rest x) (first x))
1(let [path "foo"] (clojure.string/join ":" (for [suffix ["lib/*" "src" "resources"]] (str path "/" suffix))))
"foo/lib/*:foo/src:foo/resources"(let [line "version=123:foo=bar:something=moo"] (->> (.split line ":") (map #(vec (.split % "="))) (into {})))
{"foo" "bar", "something" "moo", "version" "123"}
(let [world (vec (repeat 4 (vec (repeat 4 nil))))] (assoc-in world [3 1] 'test))
[[nil nil nil nil] [nil nil nil nil] [nil nil nil nil] [nil test nil nil]]
(let [ms [{:a 1, :b 2} {:c 3}]] (update-in ms [1] merge {:d 4}))
[{:a 1, :b 2} {:c 3, :d 4}]
(let [a '([:a 1] [:b 2])] (zipmap (map first a) (map second a)))
{:a 1, :b 2}
(let [v (promise)] (with-out-str (deliver v (do (println "DISREGARD THAT I SUCK") :value))) @v)
:value(let [v1 [:a :b :c] v2 (assoc v1 1 20)] (list v1 v2))
([:a :b :c] [:a 20 :c])
(let [v [1 2 3 4]] (concat (subvec v 0 2) (subvec v 3)))
(1 2 4)
(macroexpand '(let [[x y] [1 2]] {:keys [a b]} {:a 1, :b 2}))
(let [[x y] [1 2]] {:keys [a b]} {:a 1, :b 2})
(let [chunker (partial partition-by (fn [x] (rand-int 2)))] (interleave (chunker "abcdefghijk") (chunker (range 10))))
((\a \b \c \d) (0) (\e) (1 2 3 4) (\f \g \h \i) (5) (\j) (6 7 8) (\k) (9))
(let [[a b c] [1 2 3] b (str b)] (list a b c))
(1 "2" 3)
(let [cmd '(f a b)] `(~(first cmd) x# ~@(next cmd)))
(f x__3459776__auto__ a b)
(defmacro &-> [value & fs] `(let [v# ~value] (doto v# (some-> v# ~@fs))))
#'user/&->
(let [n 2 x (range 5)] (concat (take n x) (drop (inc n) x)))
(0 1 3 4)
(let [s "hello there!"] (map (partial apply str) (split-at (- (count s) 3) s)))
("hello the" "re!")
(let [h {:foo "bar", :foo2 "bar"}] (for [[k v] h] [(name k) (keyword v)]))
(["foo" :bar] ["foo2" :bar])
(let [a {:a 1, :b 2} b (with-meta a {:blah true})] (identical? a b))
false(let [m {:xpos 1, :ypos 2} {x :xpos, y :ypos} m] [x y])
[1 2]
(let [v [1 2 3]] (for [n (range (count v))] (take (inc n) v)))
((1) (1 2) (1 2 3))
(let [xs [1.0 2.0 3.0]] `(+ ~@(for [x xs] `(int ~x))))
(clojure.core/+ (clojure.core/int 1.0) (clojure.core/int 2.0) (clojure.core/int 3.0))
(let [x [1 2 3 4]] (remove #(= (nth x 3) %) x))
(1 2 3)
(let [[[x y] & [xs ys]] [[1 2 3] [4 5 6]]] [x y])
[1 2]
(let [a (atom 1) f '(swap! a inc)] `(if ~f (~f)))
(if (swap! a inc) ((swap! a inc)))
(let [q '(1 2 3)] ((juxt vec counted?) (concat q [4 5 6])))
[[1 2 3 4 5 6] false]
(let [f #(inc %)] (reductions #(%2 %1) 1 [f f f f]))
(1 2 3 4 5)
(let [coll (range 1 10) n 3] (apply map list (partition n coll)))
((1 4 7) (2 5 8) (3 6 9))
(let [a (atom 1) b (atom 2)] (reset! a b) (reset! b a) nil)
nil(let [f (fn [val seq] (some #{val} seq))] (f :a [:a :b :c]))
:a(let [[answer guesses :as data] [[1 2 3] [4 2 1]]] (map = data))
(true true)
(let [items (or [] "[] isn't falsy") item (or nil "but nil is")] [items item])
[[] "but nil is"]
(let [foo (partial + 1 2 3) bar (foo 4 5 6)] [bar (foo)])
[21 6]
(let [foo #(do {%1 %2})] (conj {1 2, 3 4} (foo 3 5)))
{1 2, 3 5}
(let [value false m {:first "thing"}] (and (or value m) (assoc m :test value)))
{:first "thing", :test false}
(let [{:keys [a b c], :as m} {:a 1, :b 2, :c 3}] m)
{:a 1, :b 2, :c 3}
(let [a (atom 0)] (second (map (fn [_] (swap! a inc)) (range 50))) @a)
32(let [state (atom {:plots [[1 2] [1 5]]})] (update-in @state [:plots 0 1] inc))
{:plots [[1 3] [1 5]]}
(let [[x y & more] [1 2 3 4 5]] (list x y more))
(1 2 (3 4 5))
(let [s "a/b/c/d/e"] (map #(subs s 0 (inc %)) (range 0 (count s))))
("a" "a/" "a/b" "a/b/" "a/b/c" "a/b/c/" "a/b/c/d" "a/b/c/d/" "a/b/c/d/e")
(let [m (transient {})] (doseq [i (range 10)] (assoc! m i (inc i))) (count m))
8(let [adder (fn [x] (fn inner [y] (+ x y)))] [(adder 1) (adder 2)])
[#object [sci.impl.fns$fun$arity_1__26688 0x664da3b9 "sci.impl.fns$fun$arity_1__26688@664da3b9"] #object [sci.impl.fns$fun$arity_1__26688 0x688a4100 "sci.impl.fns$fun$arity_1__26688@688a4100"]]
(let [fliebels-rand-int (fn [a b] (+ a (rand-int (- b a))))] (fliebels-rand-int 10 12))
10

