General
assoc-val
(item alist &rest key-args)
Return the value of
item
in alist
. key-args
should
contain any additional keyword arguments to assoc
.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 to
effector
on its input. This is usually useful for
effectful code, such as logging.empty-or-nil-p
(arg)
Is
arg
null, or does it represent an empty sequence? Returns
NIL if arg
is not a nil or a sequence.flip
(fn y)
Given a function
fn
that takes arguments x
and y
, return a lambda with y
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 map
fn
over the vectors vecs
, producing a vector.build-vector
(arg)
If
arg
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)
Split
seq
into a pair of sequences with pred
: the first of
the pair are those elements satisfying pred
, and the second are
those that do not satisfy pred
.