(defn fibo [] (map first (iterate (fn [[a b]] [b (+ a b)]) [0 1])))
#'user/fibo
(map (fn [q a] {:question q, :answer a}) ["q1" "q2" "q3"] ["a1" "a2" "a3"])
({:answer "a1", :question "q1"} {:answer "a2", :question "q2"} {:answer "a3", :question "q3"})
(let [a (atom 0)] (second (map (fn [_] (swap! a inc)) (range 50))) @a)
32
(map (partial apply (fn [a b] (str a "/" b))) [["" 2] [3 4]])
("/2" "3/4")
((fn prefix [a b] (every? (partial apply =) (map list a b))) "clo" "brojure")
false
(let [{:strs [a b c]} {:a 0, :b 1, :c 2}] [a b c])
[nil nil nil]
(nth (map first (iterate (fn [[a b]] [b (+ a b)]) [0N 1N])) 500)
139423224561697880139724382870407283950070256587697307264108962948325571622863290691557658876222521294125N
(let [x [1 2] a (first x) b (rest x)] [a b])
[1 (2)]
((fn f [a & b] (if (zero? a) (f 1 2 3) :ok)) 0)
:ok
(let [[x :as a & don't mind me] [0 1 2 3]] [x a])
[0 [0 1 2 3]]
(take 10 (map first (iterate (fn [[a b]] [b (+ a b)]) [1 1])))
(1 1 2 3 5 8 13 21 34 55)
(let [[a b] ((juxt + *) 2 3)] (str a " and " b))
"5 and 6"
(map (fn [a b] (str a " and " b)) [1 2 3] "a")
("1 and a")
(take 5 (map first (iterate (fn [[a b]] [b (+ a b)]) [0 1])))
(0 1 1 2 3)
(let [a [1 2 3] b [4 5 6]] (mapv + a b))
[5 7 9]
(let [a (atom {:x {:y {:z 1}}})] (swap! a update-in [:x :y :z] inc))
{:x {:y {:z 2}}}
(letfn [(foo [x & [{:keys [a]}]] [x a])] [(foo 1) (foo 1 {:a 2})])
[[1 nil] [1 2]]
(take 10 (map first (iterate (fn [[a b]] [b (+ a b)]) [0 1])))
(0 1 1 2 3 5 8 13 21 34)
(let [a {:b [:c :d]}] (doseq [[x [y z]] a] (println x y z)))
nil
":b :c :d\n"
((fn prefix [a b] (every? (partial apply =) (map list a b))) "clo" "clojure")
true
((fn [a b] (map vector a b)) [1 2 3] [:a :b :c :d])
([1 :a] [2 :b] [3 :c])
(defn f [a b c] (println (+ a (* 10 b) (* 30 c))))
#'user/f
((fn [{:keys [a b c]}] [a b c]) {:a 1, :b 2, :c 3})
[1 2 3]
(def a (filter #(do (println "hi") (symbol? %)) '[:a a 3 :b]))
#'user/a
(let [a 1 b (println a) c (println "also") d 2] d)
2
"1\nalso\n"
((fn prefix [a b] (every? (partial apply =) (map list a b))) "clojure" "clo")
true
((fn [s & {:keys [a b]}] [a b]) "duck" :a #{"quack"} :b 42)
[#{"quack"} 42]
(letfn [(foo [& {a :a, b :b}] [a b])] (foo :a 1 :b 2))
[1 2]
(let [{{a :a, b :b} :numbers} {:numbers {:a 1, :b 1}}] (+ a b))
2
(take 10 (map first (iterate (fn [[a b]] [b (+ a b)]) [1 2])))
(1 2 3 5 8 13 21 34 55 89)
(apply (fn [& {:keys [a b]}] [":a" a ":b" b]) {:a 1, :b 2})
[":a" nil ":b" nil]
(defn filter-first [pred s] (let [[a b] (split-with pred s)] (concat a (next b))))
#'user/filter-first
(let [{:keys [a b c]} {:a 1, :b 2, :c nil}] [a b c])
[1 2 nil]
(let [a [[0 12] [1 23] [3 65]] b (map #(- (first %1) (first %2) 1) a (cons [0] a))] (mapcat #(concat (repeat %1 0) [(second %2)]) b a))
(12 23 0 65)
(let [foo [1 1 1]] (second (reduce (fn [[a x] b] [a (and x (= a b))]) [(first foo) true] (rest foo))))
true
((fn flipper [[a b & rest]] (if (empty? rest) [b a] (concat [b a] (flipper rest)))) [1 2 3 4 5 6])
(2 1 4 3 6 5)
(keyword "stupid key with a space")
:stupid
(def lst '(a b c))
#'user/lst
(def a '(+ 3 4))
#'user/a
(map str '(a b c))
("a" "b" "c")
(read-string "[a b c]")
[a b c]
(macroexpand '(->> 1 (a b)))
(a b 1)
(def a (atom [1 2 3]))
#'user/a
(macroexpand-1 '(->> a (b c)))
(b c a)
(macroexpand '(-> (a) (b) (c)))
(c (b (a)))
(macroexpand-1 '(with-delete [a b] c))
(with-delete [a b] c)
(macroexpand-1 '(make-record recrec [a b]))
(make-record recrec [a b])
(macroexpand-1 '(->> x (map a)))
(map a x)
(class (seq '(a b c)))
clojure.lang.PersistentList
('a '{a 1, b 2})
1