This package contains utilities that I find useful in writing programs; that is, it is a collection of generally-useful functions and macros. Some of these I've written, and some of these derive from other sources.
The utilities can be categorised as
hash-table
functions,mkstr
: concatenates its symbols and returns the printable representation
of the resultsymb
: passes its arguments to mkstr
to produce a printable representation, and returns the symbol built
from this result; if the symbol does not exist, it will be
created.group
: takes a list as input and produces a
list of sublists of length n.flatten
: Returns a list of all atoms present in
the provided list.compose
: allows a number of functions with the same arity
to be composed together in a chain.defmacro!
: provides automatic gensyms and
once-only evaluation. Arguments that begin with g! will be
automatically gensym
'd, and arguments that begin with
o! will only be evaluated once. Inside the body, the o! arguments
should be called as their equivalent g! argument: o!x should be
called in the body as g!x.
sethash
: convenience function for setting a value
in a hash table.hashkeys
: returns a list of all the keys in a hash
table.hash-table-to-alist
: converts the hash table to an
alist of (key . value)
pairs.alist-to-hash-table
: converts an alist to a hash
table.enable-hash-table-reader
: Enables the reader
macro #{}#
for hash tables. The resulting hash-table
will use #'equal for equality. For example,
#{:a :b :c :d}#will create a hash-table with the keys
:a
and :c
. :a
stores the value :b
,
and :c
stores the value :d
.Clone into your Quicklisp project's local-projects/
subdirectory, and call (ql:quickload :kutils)
.
You can browse the Github repository.