Utilities
(ql:quickload '("alexandria" "serapeum" "str"))
;; Alexandria: the de facto standard utility library
(alexandria:flatten '(1 (2 (3)))) ; (1 2 3)
(alexandria:iota 5 :start 1) ; (1 2 3 4 5)
(alexandria:shuffle (list 1 2 3))
(alexandria:hash-table-keys ht) (alexandria:hash-table-alist ht) (alexandria:alist-hash-table alist)
(alexandria:when-let ((x (gethash :k ht))) (print x))
(alexandria:if-let ((x (find 3 list))) x :none)
(alexandria:switch ("b" :test #'string=) ("a" 1) ("b" 2) (t 0)) ; 2
(alexandria:ensure-list 5) ; (5)
(alexandria:clamp 15 0 10) ; 10
(alexandria:mean '(1 2 3 4)) ; 5/2
(alexandria:copy-hash-table ht)
(alexandria:read-file-into-string "x.txt")
(alexandria:curry #'+ 1) (alexandria:rcurry #'- 1) (alexandria:compose #'1+ #'abs)
(alexandria:destructuring-case '(:add 1 2) ((:add a b) (+ a b)) ((:neg a) (- a))) ; 3
;; Serapeum: more utilities
(serapeum:batches '(1 2 3 4 5) 2) ; ((1 2) (3 4) (5))
(serapeum:assort '(1 2 3 4) :key #'evenp) ; ((1 3) (2 4))
(serapeum:frequencies '(a b a)) ; hash
…