(let [x '[a b c]] `(example ~@x))
(user/example a b c)
(some #{'c} '(a b c d e))
c
(macroexpand '(->> (a b) (c d) (e f)))
(e f (c d (a b)))
(map vector [1 2 3] '[a b c])
([1 a] [2 b] [3 c])
(defn a [x] (letfn [(b [y] y)] (b x)))
#'user/a
(let [a (delay (println "test") 1)] (println "test2") @a)
1
"test2\ntest\n"
(def a (filter odd? (cycle [1 2 3 4])))
#'user/a
((fn fib ([n] (if (<= 2 n) (fib (- n 2) 1 1) 1)) ([n a b] (if (<= n 0) (+ a b) (recur (dec n) b (+ a b))))) 6)
13
((fn [s] (when-let [[_ a b c] (seq (re-find #"(\d+)\.(\d+)\.(\d+)" s))] [a b c])) "alpha.beta.com")
nil
(let [a #{1 3 4 5 7} b (conj a 8)] [(b 2) (b 3) (b 5) (b 6)])
[nil 3 5 nil]
(defmacro sample ([a] `(uch ~a nil)) ([a b] `(do (println "a: " '~a " b: " '~b) ~a ~b)))
#'user/sample
(with-meta '(1 2 3) {:type :print-fn, :print-fn #(str "#<I am a list with a " (first %) " >")})
(1 2 3)
(defmacro daset [a vals] `(do ~@(for [[idx val] (partition 2 vals)] `(aset ~(with-meta a {:tag 'doubles}) ~idx ~val))))
#'user/daset
(->> [[:a 50] [:a 10] [:a 30] [:b 20]] (map (fn [[a b]] [a [b]])) (map (partial apply hash-map)) (apply merge-with concat))
{:a (50 10 30), :b [20]}
(mapv (fn [a b mask] (if (zero? mask) a b)) [1 2 3 4] [4 3 2 1] [1 1 0 0])
[4 3 3 4]
(let [a [[1 2 3] [1 5 6]] b ["abc" "def"]] (into {} (mapcat #(map (fn [k] [k %2]) %1) a b)))
{1 "def", 2 "abc", 3 "abc", 5 "def", 6 "def"}
((fn [x y & {:keys [a b c], :or {a 5}, :as m}] (if (every? (set (keys m)) [:b :c]) [x y a b c m] "error")) 1 2 :c 3 :b 6)
[1 2 5 6 3 {:b 6, :c 3}]
(let [a (set (range 0 1e5)) b (set (range 0 1e5 3))] (reduce #(if (a %2) (inc %) %) 0 b))
33334
(apply (fn x [& {:keys [a b c]}] {:a2 a, :b2 b, :c2 c}) (apply concat {:a 1, :b 2, :c 3}))
{:a2 1, :b2 2, :c2 3}
(#(let [[[a] [_ b] [_ _ c]] %] [a b c]) '((1 2 3) (4 1 6) (7 8 1)))
[1 1 1]
(apply str (let [a "eda?we ie oc hk otShswnntr"] (map #(get a (mod (* 15 (- % 4)) 26)) (range 26))))
"Since when does that work?"
(let [a (set [1 3 2]) b #{1 2 3} c #{3 2 1}] (= a b c))
true
(let [a (set (range 0 6)) b (set (range 0 10 2))] (reduce #(if (a %2) (inc %) %) 0 b))
3
(let [nodes (range 6) decorators (-> (map (fn [a b] a) (repeat "|--") (rest nodes)) (concat ["`--"]))] (map str decorators nodes))
("|--0" "|--1" "|--2" "|--3" "|--4" "`--5")
(defn swap!-old [a f & args] (let [old (atom nil)] (swap! a #(do (reset! old %) (apply f % args))) @old))
#'user/swap!-old
(let [nodes (range 6) decorators (-> (map (fn [a b] a) (repeat "|--") (rest nodes)) (concat ["`--"]))] (map str nodes decorators))
("0|--" "1|--" "2|--" "3|--" "4|--" "5`--")
(defn swap! [a f & args] (loop [] (let [old-val @a new-val (apply f old-val args)] (if (compare-and-set! a old-val new-val) new-val (recur)))))
#'user/swap!
(let [{{:keys [a b c], :as p} :p, :as r} {:p {:a 1, :b 2, :c 3}}] [a b c p r])
[1 2 3 {:a 1, :b 2, :c 3} {:p {:a 1, :b 2, :c 3}}]
(map (partial apply concat) (partition 2 (partition-by '#{a e h} '[a b c d e f g h i j])))
((a b c d) (e f g) (h i j))
(let [[a b] (seq #{1 2 3 4})] b)
4
(apply map list '[[a b] [c d] [e f]])
((a c e) (b d f))
(filter symbol? (tree-seq coll? identity '{:keys [a b [c]]}))
(a b c)
(map list '(1 2 3) '(a b c))
((1 a) (2 b) (3 c))
(macroexpand '(let [a 1] (-> 1 inc (* 2))))
(let [a 1] (-> 1 inc (* 2)))
(filter sequential? '(1 (a (eqsd vsa)) 5 6 (7) ()))
((a (eqsd vsa)) (7) ())
(filter (comp not nil?) '(a b c nil d))
(a b c d)
(map str '(a b c) [1 2 3] "?!@")
("a1?" "b2!" "c3@")
(printf "feels odd to have to insert a %s\n" "newline-char")
nil
"feels odd to have to insert a newline-char\n"
(map vector '(a b c) '(d e f))
([a d] [b e] [c f])
(clojure.string/replace "a word in a string" #"(word)" "**$1**")
"a **word** in a string"
(when-not (list? (cons 1 nil)) (println "what a crappy function"))
nil
(let [xs [1 2 3]] `(foo a ~xs b))
(user/foo user/a [1 2 3] user/b)
((fn [a b c d] b) 1 2 3 4)
2
(macroexpand '(->> a b (->> (c d) (->> e))))
(b a (->> e (c d)))
(defmacro -l [a b] `(- (long ~a) (long ~b)))
#'user/-l
(let [[a & [b]] [1 2 3 4 5]] b)
2
(let [[a & rest :as all] [1 2 3]] all)
[1 2 3]
(apply map vector '((a b) (c d) (e f)))
([a c e] [b d f])
(if-let [[a b] [false {:error "Not valid"}]] "Valid" "Not valid")
"Valid"
(pr-str '(ns a (:use foo) (:require [bar :as b])))
"^{:line 1, :column 10} (ns a ^{:line 1, :column 16} (:use foo) ^{:line 1, :column 27} (:require [bar :as b]))"