Core Sequence Functions

(def nums [5 3 8 1 9 2])

;; Transform and filter
(map #(* 2 %) nums)                  ; (10 6 16 2 18 4)
(map + [1 2 3] [10 20 30])           ; (11 22 33)
(map-indexed vector [:a :b])         ; ([0 :a] [1 :b])
(filter odd? nums) (remove odd? nums)
(keep #(when (> % 4) (* % 10)) nums) ; (50 80 90): map + drop nils
(mapcat (fn [x] [x x]) [1 2])        ; (1 1 2 2)
(distinct [1 2 1 3])                 ; (1 2 3)
(dedupe [1 1 2 2 1])                 ; (1 2 1)

;; Aggregate
(reduce + nums)                      ; 28
(reduce (fn [acc x] (conj acc (* x x))) [] [1 2 3])   ; [1 4 9]
(reduce-kv (fn [m k v] (assoc m k (inc v))) {} {:a 1})   ; {:a 2}
(apply + nums) (count nums)
(frequencies "hello")                ; {\h 1, \e 1, \l 2, \o 1}
(group-by count ["a" "bb" "cc" "d"]) ; {1 ["a" "d"], 2 ["bb" "cc"]}
(partition-by odd? [1 3 2 4 5])      ; ((1 3) (2 4) (5))
(partition 2 [1 2 3 4 5])            ; ((1 2) (3 4))
(partition-all 2 [1 2 3 4 5])        ; ((1 2) (3 4) (5))
(split-at 2 [1 2 3 4])               ; [(1 2) (3 4)]
(split-with #(< % 3) [1 2 3 1])      ; [(1 2) (3 1)]

;; Order and select
(sort nums)                          ; (1 2 3 5 8 9)
(sort > nums)                        ; descendin
…