- General
-
assoc-val
(item alist &rest key-args)
Return the value ofitem
inalist
.key-args
should contain any additional keyword arguments toassoc
.build-list
(arg)
If arg is an atom, return it as a list. If it's a list, return the arg. If it's a vector, coerce it to a list. Otherwise, return nil.cartprod2
(a b)
Produce the cartesian product of the two lists.* (cartprod2 '(a b c) '(1 2 3 4)) ((A . 1) (A . 2) (A . 3) (A . 4) (B . 1) (B . 2) (B . 3) (B . 4) (C . 1) (C . 2) (C . 3) (C . 4))
effector
(&rest fns)
An effector returns a function that calls all the functions supplied toeffector
on its input. This is usually useful for effectful code, such as logging.empty-or-nil-p
(arg)
Isarg
null, or does it represent an empty sequence? Returns NIL ifarg
is not a nil or a sequence.flip
(fn y)
Given a functionfn
that takes argumentsx
andy
, return a lambda withy
applied to the function.CL-USER> (format t "(- 7 3) -> ~A~%" (funcall (flip #'- 3) 7)) (- 7 3) -> 4 NIL
macroexpand-n
(n form)
Expand the macro n times.mksymb
(&rest args)
Create a symbol from arguments, upcasing strings as required.mkkw
(&rest args)
Create a keyword from its arguments.zip
(&rest lsts)
Zip together elements from each list. For example,* (zip '(a b c) '(1 2 3)) '((a 1)(b 2)(c 3)).
- Vector-related
-
new-vector
nil
Create a new, empty, adjustable vector with fill pointer.mapv
(fn &rest vecs)
Utility to mapfn
over the vectorsvecs
, producing a vector.build-vector
(arg)
Ifarg
is an atom, return it as a list. If it's a list, coerce it to a vector. If it's a vector, return the vector. Otherwise, attempt to map it into a vector.extend-vector
(v)
Create a new vector from the contents of its argument where the new vector is adjustable and has a fill pointer set. - Clojure-inspired functions
-
interpose
(x sep)
Takes a list and a separator, and places separator between element of the list.take
(n lst)
Take n elements from lst.drop
(n lst)
Drop n elements from the list.partial
(fn &rest initial-args)
partial provides partial function application. It returns a lambda that will call the function given with the intial args and any additional args provided to the lambda.partition
(pred seq)
Splitseq
into a pair of sequences withpred
: the first of the pair are those elements satisfyingpred
, and the second are those that do not satisfypred
.