(println "This is a stick-up")
nil
"This is a stick-up\n"
(get '{a 2} 'a)
2
(apply hash-map '[a b])
{a b}
(sequential? '[a b c])
true
(def a (map str 'foo))
#'user/a
(clojure.string/join \space '(a b))
"a b"
(class '(a b c))
clojure.lang.PersistentList
(def ^{:foo :bar} a)
#'user/a
(let [a 1] "HELLO WORLD")
"HELLO WORLD"
(macroexpand '(let [a 1]))
(let [a 1])
(vec '(a b c))
[a b c]
(let [a 5] `[~a])
[5]
(defrecord A [c b g])
#'user/A
(meta '^:bar [a b c])
{:bar true}
(let [a "a"] (class #'a))
java.lang.String
(defrecord Location [a b c])
#'user/Location
(let [a (atom 8)] @a)
8
(pr "clojurebot is a donkey")
nil
"\"clojurebot is a donkey\""
(loop [a 0] (when (< a 10) (loop [b 0] (when (< b 10) (recur (inc b)))) (recur (inc a))))
nil
(let [a (sort-by #(< 1 (val %)) {:a 1, :b 2, :c 5, :d 0})] (pr a) (into {} a))
{:a 1, :b 2, :c 5, :d 0}
"([:a 1] [:d 0] [:b 2] [:c 5])"
(doseq [{a :a, b :b, :or {a 1, b 2}} #{{:a 3} {:b 4}}] (println a " " b))
nil
"3 2\n1 4\n"
(let [a (+ 23 24)] (doseq [b (range 24 48)] (print (mod (min (- a b) (- b a)) 24))))
nil
"12345678910111213141516171819202122230"
(for [a (range 1 10) b (range 1 10) c (range 1 10) :when (= (* c c) (+ (* a a) (* b b))) :when (= 24 (+ a b c))] [a b c])
()
(let [foo (fn [a] (if (= 0 (get a 0)) a (recur (update-in a [0] dec))))] (foo [10 9 8 7 6 5 4 3 2 1 0]))
[0 9 8 7 6 5 4 3 2 1 0]
(apply merge-with (fn [a b] (if (vector? a) (conj a b) (vector a b))) [{:a {:c 2, :b 1}} {:a {:c 3, :b 4}} {:a {:c 4}}])
{:a [{:b 1, :c 2} {:b 4, :c 3} {:c 4}]}
(defn combine [a & rest] (letfn [(vectorize [v] (into {} (map (fn [[k v]] [k [v]]) v)))] (reduce (fn [a b] (merge-with into a (vectorize b))) (vectorize a) rest)))
#'user/combine
(let [a (into-array [1 2 3 4 5]) s (seq a)] (println (first s) ".") (aset a 0 42) (println (first s) ".") (println (aget a 0) "."))
nil
"1 .\n42 .\n42 .\n"
(let [{a :a, :as m} (list 1 2 3 4)] (println a m))
nil
"nil {1 2, 3 4}\n"
(defn otherfn [a b c & args] (println (conj args c b a)))
#'user/otherfn
(let [foo :as {:keys [a b]} {:a 1, :b 2}] [a b foo])
[1 2 :as]
(defmacro foo [a] (let [bar (+ a 2)] `(fn [] (* ~bar 3))))
#'user/foo
(reduce (fn [a b] (+ (val a) (val b))) {:a 1, :b 2})
3
(let [a (atom (map #(print %) (range 35)))] (swap! a rest) nil)
nil
"012345678910111213141516171819202122232425262728293031"
(let [x [1 2] [a b] x] {:x x, :a a, :b b})
{:a 1, :b 2, :x [1 2]}
(defmacro test [& a] `(fn [d#] (-> d# ~@(map eval a))))
#'user/test
(let [[a b] [:key "val"]] (str "key: " a " val: " b))
"key: :key val: val"
(let [{:syms [a b]} {'a 1, 'b 3, 'c 3}] (+ a b))
4
((fn [[a b c]] {:a a, :b b, :c c}) [1 2 3])
{:a 1, :b 2, :c 3}
(defn comparator-from [literals] (fn [a b] (- (.indexOf literals a) (.indexOf literals b))))
#'user/comparator-from
(let [{:keys [a b]} {:a 1, :b 2}] (format "a=%d, b=%d" a b))
"a=1, b=2"
(let [f (fn [{a :name, b :age}] (str a b))] (f {:age 9}))
"9"
(do (def a 1) (let [f (comp #'a)] (with-redefs [a (constantly 2)] f)))
#'user/a
(let [{a :a, :as m} (list 1 2 :a 4)] (println a m))
nil
"4 {1 2, :a 4}\n"
(do (require '[clojure.walk :as walk]) (walk/macroexpand-all '(quote (let [a 1] a))))
(quote (let [a 1] a))
(reduce (fn [a b] (doall (map + a b))) (repeat 10000 [1 1]))
(10000 10000)
(for [a (range 10) :let [b (* a 3)] :when (odd? b)] b)
(3 9 15 21 27)
(let [[a & [b & c]] [1 2 3 4]] [a b c])
[1 2 (3 4)]
(let [{:syms [a b c]} '{a 1, b 2, c 3}] b)
2
(map (fn [a b] #(.replace % a b)) (seq "_-") (seq "/+"))
(#object [sci.impl.fns$fun$arity_1__26688 0xbdb1f50 "sci.impl.fns$fun$arity_1__26688@bdb1f50"] #object [sci.impl.fns$fun$arity_1__26688 0x51cf05b "sci.impl.fns$fun$arity_1__26688@51cf05b"])
(let [a (atom 0) b (seque 5 (repeatedly #(swap! a inc)))] @a)
0