(->> (repeat (range)) (map #(map str %)) (map #(map first %)) (map rest) (map #(take 2 %)) (take 2))
((\1 \2) (\1 \2))
(let [ms [{:id 1, :x 1} {:id 2, :x 2} {:id 1, :x 3}]] (->> ms (map (juxt :id identity)) (into {}) (vals)))
({:id 1, :x 3} {:id 2, :x 2})
(->> [\A \Z \a \z \0 \9] (map int) (partition 2) (map (fn [[l h]] (range l h))) (apply concat) (map char))
(\A \B \C \D \E \F \G \H \I \J \K \L \M \N \O \P \Q \R \S \T \U \V \W \X \Y \a \b \c \d \e \f \g \h \i \j \k \l \m \n \o \p \q \r \s \t \u \v \w \x \y \0 \1 \2 \3 \4 \5 \6 \7 \8)
(mapv #(hash-map :a %) (flatten (mapv #(->> % vals first) [{:a 1} {:a 2} {:a [3 4 5]} {:a 6}])))
[{:a 1} {:a 2} {:a 3} {:a 4} {:a 5} {:a 6}]
(defn get-name [] (->> 'clojure.core ns-publics keys (mapcat (fn [s] (clojure.string/split (name s) #"-"))) shuffle (take (inc (rand-int 3))) (clojure.string/join \-) symbol))
#'user/get-name
(let [f (fn [n m] (conj (->> n range (partition (int (/ n m))) (map first) vec) n))] (f 100 3))
[0 33 66 100]
(->> {:a {:b 'c, :d {:e 'f}, :g {:e 'h}}} (tree-seq map? vals) (filter #(and (map? %) (some '#{f} (vals %)))))
({:e f})
(->> [{:a "x", :b 1} {:a "y", :b 1} {:a "x", :b 1}] frequencies (map (fn [[{a :a} b]] [a b])) (reduce merge {}))
{"x" 2, "y" 1}
(letfn [(pile [n cards] (let [cards (reverse cards)] (->> (range n) (mapcat #(take-nth n (drop % cards))))))] (pile 3 (range 1 11)))
(10 7 4 1 9 6 3 8 5 2)
(letfn [(char-set [c] (->> c (map char) set))] (= (char-set "the quick brown fox jumps over the lazy dog") (char-set (range 97 123))))
false(letfn [(pile [n cards] (->> (range (dec n) -1 -1) (mapcat #(take-nth n (drop % cards))) reverse))] (pile 3 (range 1 11)))
(10 7 4 1 8 5 2 9 6 3)
((fn [& args] (->> args (iterate next) (take-while identity) (filter (comp #{:foo} first)) first second)) 1 2 :foo 3 4 5 6)
3(defn n [i] (->> (all-ns) (mapcat ns-publics) keys (mapcat #(clojure.string/split (name %) #"[*-.!?]")) shuffle (take i) (clojure.string/join \-) symbol))
#'user/n
(->> [{:age 1} {:age 1} {:age 1} {:age 2} {:age 2} {:age 3}] (map :age) (frequencies) (vals) (map dec) (reduce + 0))
3((fn [coll] (->> coll (partition 2 1) (map (fn [[[a x] [b y]]] [[a b] (- y x)])))) [["a" 1] ["b" 5] ["c" 7]])
([["a" "b"] 4] [["b" "c"] 2])
(let [g (->> (gensym) str (re-find #"\d+") (#(Integer/parseInt %)) inc inc inc (str "G__") symbol)] ((juxt identity eval) `(let [~g (gensym)] ~g)))
[(clojure.core/let [G__1218876 (clojure.core/gensym)] G__1218876) G__1218876]
((fn [& seqs] (->> seqs (map #(concat % (repeat nil))) (apply map vector) (take-while #(not-every? nil? %)))) [1 2 3] [4 5] [6])
([1 4 6] [2 5 nil] [3 nil nil])
(defn partition-with [p coll] (let [seps (concat (map p coll (rest coll)) [true])] (->> (map list seps coll) (partition-by second) (map #(map second %)))))
#'user/partition-with
(->> 'clojure.core ns-publics keys (map name) (map #(clojure.string/split % #"-")) (filter #(> (count %) 1)) (filter #(every? (comp resolve symbol) (remove empty? %))))
(["chunk" "first"] ["when" "first"] ["take" "last"] ["take" "nth"] ["rand" "int"] ["aset" "long"] ["rand" "nth"] ["aset" "float"] ["take" "while"] ["prn" "str"] ["" ">"] ["aset" "double"] ["chunk" "rest"] ["aset" "boolean"] ["when" "not"] ["namespace" "munge"] ["aset" "char"] ["pr" "str"] ["aset" "short"] ["aset" "byte"] ["hash" "set"] ["extend" "type"] ["not" "every?"] ["cond" ">"] ["aset" "int"]...
(let [c [{:step 1, :pos :s1} {:step 2, :pos :s2} {:step 5, :pos :s1}]] (->> (map #(hash-map (:pos %) [(:step %)]) c) (apply merge-with into)))
{:s1 [1 5], :s2 [2]}
(defmacro list+ [& forms] (->> forms (map (fn [x] (if (and (symbol? x) (not (contains? &env x)) (not (resolve x))) (str x) x))) (cons `list)))
#'user/list+
(defn make-name [] (let [namespaces (all-ns) namespace (->> namespaces (mapcat #(clojure.string/split (name (.name %)) #"[.-]")) shuffle (take (+ 2 (rand-int 4))) (clojure.string/join ".")) variable (->> namespaces (mapcat ns-publics) (mapcat #(clojure.string/split (name (key %)) #"[-*!?]")) shuffle (remove empty?) (take (+ 2 (rand-int 3))) (clojure.string/join "-"))] (symbol (str namespace \/ variable))))
#'user/make-name
(->> rand repeatedly (partition 4) (take 20) (map (juxt identity #(apply hash-map %))) (map #(map (comp flatten seq) %)) (map #(apply = %)) set)
#{false true}
(->> [{:a {:c 2, :b 1}} {:a {:c 3, :b 4}} {:a {:c 4}}] (apply concat) (reduce (fn [m [k v]] (update-in m [k] (fnil conj []) v)) {}))
{:a [{:b 1, :c 2} {:b 4, :c 3} {:c 4}]}
(->> ["7" "7 elements" "7 elements landing" "7 elements landing page" "add"] (partition 2 1 nil) (remove (fn [[a b]] (and b (.contains b a)))) (map first))
("7 elements landing page" "add")
(defn factor [n] (let [[p] (->> (range) (drop 2) (filter #(zero? (rem n %))))] (if (= n p) [n] (cons p (factor (/ n p))))))
#'user/factor
(->> (map (fn [a] (a)) (list #(/ 1 1) #(/ 1 0) #(/ 1 2))) (cons 123) (drop-while #(= % 123)) first)
1(defn make-name [] (->> (all-ns) (mapcat ns-publics) (mapcat #(clojure.string/split (name (key %)) #"[-*!?]")) shuffle (remove empty?) (take (+ 2 (rand-int 3))) (clojure.string/join "-") symbol))
#'user/make-name
(for [delim ["^" "-" "*" "\\" "?" "]"]] (clojure.string/split (str "hello" delim "world") (re-pattern (str "[" (->> delim first int (format "%04x") (str "\\u")) "]"))))
(["hello" "world"] ["hello" "world"] ["hello" "world"] ["hello" "world"] ["hello" "world"] ["hello" "world"])
(reduce clojure.set/intersection (for [rec-vector [[{:id 1} {:id 2} {:id 3}] [{:id 1} {:id 2} {:id 4}] [{:id 1} {:id 2} {:id 3}]]] (->> rec-vector (map :id) (set))))
#{1 2}
(->> '((0 1 2) (3 4 5) (6 7 8) (9 10 11)) (map vector (cycle [0 1])) (reduce (fn [v [i x]] (update-in v [i] into x)) [[] []]))
[[0 1 2 6 7 8] [3 4 5 9 10 11]]
(let [f (fn [s] (->> (iterate #(.indexOf s "<C>" (inc %)) -1) (drop 1) (take-while (complement neg?))))] (f "la la la <C> la la <C> <C> foo <C>"))
(9 19 23 31)
(let [sums (reductions + [1 2 3 4 5 6 7 8 9 4]) total (last sums)] (->> (partition 2 1 sums) (map (fn [[a b]] [a b total]))))
([1 3 49] [3 6 49] [6 10 49] [10 15 49] [15 21 49] [21 28 49] [28 36 49] [36 45 49] [45 49 49])
(for [delim ["?" "]" "[" "{"]] (clojure.string/split (str "hello" delim "world") (re-pattern (str "[" (->> delim first int (format "%04x") (str "\\u")) "]"))))
(["hello" "world"] ["hello" "world"] ["hello" "world"] ["hello" "world"])
(def fizzbuzz (letfn [(fb [s k coll] (mapcat (fn [x] (cons s (rest x))) (partition k coll)))] (->> (range) (fb "fizz" 3) (fb "buzz" 5) (fb "fizzbuzz" 15))))
#'user/fizzbuzz
(let [n 5/7] (->> #(random-sample n (range 10)) (repeatedly) (map-indexed list) (filter (fn [[index item]] (and (> (count item) 1) (not (zero? (last item))) (= n (apply / item))))) (ffirst)))
5319(defn times-to-get-to-fraction [n x] (->> #(random-sample n (range x)) (repeatedly) (map-indexed list) (filter (fn [[index item]] (and (> (count item) 1) (not (zero? (last item))) (= n (apply / item))))) (ffirst)))
#'user/times-to-get-to-fraction
(->> [1 2 3 4 0 1 2 1 3 4 5 6 2 3 0] (partition 2 1) (partition-by (fn [[x y]] (< x y))) (map count) (apply max) (+ 1))
5(let [n 1/7] (->> #(random-sample n (range 10)) (repeatedly) (map-indexed list) (filter (fn [[index item]] (and (> (count item) 1) (not (zero? (last item))) (= n (apply / item))))) (ffirst)))
198(let [coll [1 2 3 3 4 5 4 6 7 8 9 6 6] singles (->> coll frequencies (filter #(= (last %) 1)) (map first))] (remove (set singles) coll))
(3 3 4 4 6 6 6)
(first (let [m [[1 2] [3 4]]] (for [x '(0 1) y '(0 1) :let [elt (get-in m (doto [x y] (->> (println "trying"))))] :when (= elt 3)] [x y])))
[1 0]
"trying [0 0]\ntrying [0 1]\ntrying [1 0]\n"(let [coll (range 1 25) target 12 cnt (count coll)] (->> (for [a (range 0 cnt) b (range 1 cnt)] [(nth coll a) (nth coll b)]) (filter (fn [[x y]] (= target (+ x y))))))
([1 11] [2 10] [3 9] [4 8] [5 7] [6 6] [7 5] [8 4] [9 3] [10 2])
((fn [v] (->> v (map-indexed vector) (mapcat (fn [[i x]] (map #(-> [i %]) (range 2 (inc x))))) (reductions (fn [v [i x]] (assoc v i x)) (vec (repeat (count v) 1))))) [2 1 4])
([1 1 1] [2 1 1] [2 1 2] [2 1 3] [2 1 4])
((fn [p s] (->> [nil s] (iterate (fn [[_ [_ & xs]]] (split-with (complement p) xs))) (partition 2 1) (map (fn [[[_ [i]] [r]]] (cons i r))) (take-while first))) #{1} [1 2 2 1 3 3 1 4 4])
((1 2 2) (1 3 3) (1 4 4))
((fn [p s] (->> [nil s] (iterate (fn [[_ [_ & xs]]] (split-with (complement p) xs))) (partition 2 1) (map (fn [[[_ [i]] [r]]] (cons i r))) (take-while first))) #{1} [1 2 3 4 1 5 6 7 1 8 1 9 1 1 1 2 1])
((1 2 3 4) (1 5 6 7) (1 8) (1 9) (1) (1) (1 2) (1))
(count (->> [[8592 8703] [9027 9032] [9036 9037] [9039 9040] [9043 9044] [9046 9047] [9166] [9650] [9654] [9660] [9664] [9735 9736] [10132] [10136 10159] [10161 10174] [10224 10239] [10496 10538] [10541 10569] [10578 10619] [11008 11025]] (mapcat #(apply (fn ([x] [x]) ([x y] (range x (inc y)))) %)) (map char) (apply str)))
320(->> [[8592 8703] [9027 9032] [9036 9037] [9039 9040] [9043 9044] [9046 9047] [9166] [9650] [9654] [9660] [9664] [9735 9736] [10132] [10136 10159] [10161 10174] [10224 10239] [10496 10538] [10541 10569] [10578 10619] [11008 11025]] (mapcat #(apply (fn ([x] [x]) ([x y] (range x (inc y)))) %)) (map char) (apply str))
"←↑→↓↔↕↖↗↘↙↚↛↜↝↞↟↠↡↢↣↤↥↦↧↨↩↪↫↬↭↮↯↰↱↲↳↴↵↶↷↸↹↺↻↼↽↾↿⇀⇁⇂⇃⇄⇅⇆⇇⇈⇉⇊⇋⇌⇍⇎⇏⇐⇑⇒⇓⇔⇕⇖⇗⇘⇙⇚⇛⇜⇝⇞⇟⇠⇡⇢⇣⇤⇥⇦⇧⇨⇩⇪⇫⇬⇭⇮⇯⇰⇱⇲⇳⇴⇵⇶⇷⇸⇹⇺⇻⇼⇽⇾⇿⍃⍄⍅⍆⍇⍈⍌⍍⍏⍐⍓⍔⍖⍗⏎▲▶▼◀☇☈➔➘➙➚➛➜➝➞➟➠➡➢➣➤➥➦➧➨➩➪➫➬➭➮➯➱➲➳➴➵➶➷➸➹➺➻➼➽➾⟰⟱⟲⟳⟴⟵⟶⟷⟸⟹⟺⟻⟼⟽⟾⟿⤀⤁⤂⤃⤄⤅⤆⤇⤈⤉⤊⤋⤌⤍⤎⤏⤐⤑⤒⤓⤔⤕⤖⤗⤘⤙⤚⤛⤜⤝⤞⤟⤠⤡⤢⤣⤤⤥⤦⤧⤨⤩⤪⤭⤮⤯⤰⤱⤲⤳⤴⤵⤶⤷⤸⤹⤺⤻⤼⤽⤾⤿⥀⥁⥂⥃⥄⥅⥆⥇⥈⥉⥒⥓⥔⥕⥖⥗⥘⥙⥚⥛⥜⥝⥞⥟⥠⥡⥢⥣⥤⥥⥦⥧⥨⥩⥪⥫⥬⥭⥮⥯⥰⥱⥲⥳⥴⥵⥶⥷⥸⥹⥺⥻⬀⬁⬂⬃⬄⬅⬆⬇⬈⬉⬊⬋⬌⬍⬎⬏⬐⬑"(def ddr (fn [] (->> [[8592 8703] [9027 9032] [9036 9037] [9039 9040] [9043 9044] [9046 9047] [9166] [9650] [9654] [9660] [9664] [9735 9736] [10132] [10136 10159] [10161 10174] [10224 10239] [10496 10538] [10541 10569] [10578 10619] [11008 11025]] (mapcat #(apply (fn ([x] [x]) ([x y] (range x (inc y)))) %)) (map (comp symbol str char)) rand-nth)))
#'user/ddr

