(map list [1 2 3] '[a b c])
((1 a) (2 b) (3 c))
(let [s '#{a b c d}] (s 'e))
nil
(defn foo [a & b] (if (b) (print b)))
#'user/foo
(partition 2 1 ['a] '(a b c d))
((a b) (b c) (c d) (d a))
(reduce (partial list '.) '(a b c d))
(. (. (. a b) c) d)
(if-let [{a :a} {:b 1}] (println "foo") (println "bar"))
nil
"foo\n"
(reduce (partial apply assoc) {} '((a 10) (b 20)))
{a 10, b 20}
(defmacro crazy-thing [a b] `(defrecord R [~a ~b]))
#'user/crazy-thing
(-> cdr a is car other my quote flatten)
(my other car is a cdr)
((fn [[a & b]] b) '(1 2 3))
(2 3)
(map str '(a b c) [1 2 3])
("a1" "b2" "c3")
(defn my-set [& args] (let [order (zipmap args (range))] (apply sorted-set-by (fn [a b] (- (order a) (order b))) args)))
#'user/my-set
((fn [l r] (mapcat #(map (fn [a] (vector a %1)) l) r)) #{1 2 3} #{4 5})
([1 4] [3 4] [2 4] [1 5] [3 5] [2 5])
(let [l1 ["a" "b" "c"] l2 [true false true]] (filter identity (map (fn [a b] (and b a)) l1 l2)))
("a" "c")
(let [f (fn [& {:keys [a b c], :or {a 1, b 2, c 3}, :as params}] (println params))] (f))
nil
"nil\n"
(let [[a b] (split-with #(not= \: (first %)) '("a" "b" "c" ":d" "e"))] (concat a [(apply str b)]))
("a" "b" "c" ":de")
((fn f [s] (str \( (apply str (map #(if (list? %) (f %) %) s)) \))) '((E (C) (F I) F) (A A) H ((G) B) ((E G (I (I I A)) H I) (B) (A) C (D (H))) (F C C)))
"((E(C)(FI)F)(AA)H((G)B)((EG(I(IIA))HI)(B)(A)C(D(H)))(FCC))"
(defn map-walk [m] (if (map? m) (reduce (fn [a [k v]] (assoc a (-> k name keyword) (map-walk v))) {} m) m))
#'user/map-walk
(map (fn [[a b c & [d :as has-d]]] [a b c d has-d]) [[1 2 3 4] [5 6 7]])
([1 2 3 4 (4)] [5 6 7 nil nil])
(pr-str (let [[a b] (split-with (partial not= 3) [5 4 3 2 1 2 3 4 5])] (concat a (rest b))))
"(5 4 2 1 2 3 4 5)"
(reduce + (filter even? (take-while #(< % 4e6) (map first (iterate (fn [[a b]] [b (+ a b)]) [0 1])))))
4613732
(let [{{:keys [a b c], :as p} :p, :as r} {:p {:a 1, :b 2, :c 3}}] [a b c r])
[1 2 3 {:p {:a 1, :b 2, :c 3}}]
(let [a (atom 0) f (fn [x] (swap! a + x)) g (fn [] (println "a =" @a))] (g) (f 10) (g))
nil
"a = 0\na = 10\n"
(reduce (fn [occurances [a b]] (update-in occurances [a b] (fnil inc 0))) {} (partition 2 1 ["a" "b" "c" "d" "b" "a"]))
{"a" {"b" 1}, "b" {"a" 1, "c" 1}, "c" {"d" 1}, "d" {"b" 1}}
(defmacro sample ([a] `(sample ~a nil)) ([a b] `(do (println "a: " '~a " b: " '~b) ~a ~b)))
#'user/sample
(defn replicate-header-value [col data] (reductions (fn [a b] (if (empty? (nth b col)) (assoc b col (nth a col)) b)) data))
#'user/replicate-header-value
(let [s "12 3 456"] (when-let [[_ a b c] (seq (re-find #"(\d+) (\d+) (\d+)" s))] [a b c]))
["12" "3" "456"]
(for [s [['(1 2 3) '(4 5 6)] '(7 8 9)] a (if (vector? s) s [s])] a)
((1 2 3) (4 5 6) (7 8 9))
(defn foo [a b c & keyargs] (let [{:keys [d e f]} (apply hash-map keyargs)] [a b c d e f]))
#'user/foo
(let [a {:a 0, :b 1, :c 2} b {:b 3, :c :4, :d 5, :e 6}] (select-keys b (keys a)))
{:b 3, :c :4}
(let [mymap {:a 1, :b 2, :c 3, :d 4}] (let [{:keys [a b c d]} mymap] [a b c d]))
[1 2 3 4]
(let [l [{:key "a", :val "a"} {:key "b", :val "b"} {:key "c", :val "c"}]] (for [a l b l] [a b]))
([{:key "a", :val "a"} {:key "a", :val "a"}] [{:key "a", :val "a"} {:key "b", :val "b"}] [{:key "a", :val "a"} {:key "c", :val "c"}] [{:key "b", :val "b"} {:key "a", :val "a"}] [{:key "b", :val "b"} {:key "b", :val "b"}] [{:key "b", :val "b"} {:key "c", :val "c"}] [{:key "c", :val "c"} {:key "a", :val "a"}] [{:key "c", :val "c"} {:key "b", :val "b"}] [{:key "c", :val "c"} {:key "c", :val "c"}])
(let [square (fn [x] (* x x)) sum-squares (fn [& a] (apply + (map square a)))] (sum-squares 1 2 3 4))
30
(let [{{:keys [a b]} :c, :keys [d e]} {:c {:a 0, :b 1}, :d 2, :e 3}] [a b d e])
[0 1 2 3]
(let [{a :alpha, :keys [b c d], :as all} {:alpha 1, :b 2, :x 3}] [a b c d all])
[1 2 nil nil {:alpha 1, :b 2, :x 3}]
((fn [s] (when-let [[_ a b c] (seq (re-find #"(\w+)\.(\w+)\.(\w+)" s))] [a b c])) "alpha.beta.com")
["alpha" "beta" "com"]
(zipmap '[a b c] '(1 2 3))
{a 1, b 2, c 3}
(defmacro infix [[a op b]] `(~op ~a ~b))
#'user/infix
((fn [& [[a b]]] b) [1 2 3 4])
2
((fn [& [a b c]] c) 1 2 3)
3
(clojure.string/replace "xyz" #"x(.)z" (fn [[_ a]] "\\"))
"\\"
(defn a ([{a1 :a1}] ("something")) ([{a2 :a2}] ("something else")))
#'user/a
(re-find #"needle" "There is a needle in the haystack")
"needle"
((fn [a b & c] c) 1 2 3)
(3)
(binding [*print-meta* true] (prn (macroexpand '^String (or a b))))
nil
"^{:line 1, :column 49, :tag String} (or a b)\n"
((fn [[a b]] b) (seq {:a 0, :b 1}))
[:b 1]
(assoc '[a b c d e] 2 'X)
[a b X d e]
(class (first (partition 2 '[a b c d])))
clojure.lang.LazySeq
(let [v (def a)] [(meta v) (identical? v #'a)])
[{:file nil, :name a, :ns #object [sci.impl.vars.SciNamespace 0x37a47b18 "user"]} true]
(read-string "(defn a [b c] d e)")
(defn a [b c] d e)