kutils ยป Alphabetical list

Alphabetical documentation for all exported symbols in kutils.

kutils

alist-to-hash-table(alist)
Converts the alist to a hash-table.
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.
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.
cartprod2(a b)
Produce the cartesian product of the two lists.
compose(&rest fns)
Compose allows a number of functions with the same arity to be composed together in a chain.
condlet(bindings &body forms)
Evaluate bindings in a let form, then evaluate forms in a cond.
condlet*(bindings &body forms)
Evaluate bindings in a let* form, then evaluate forms in a cond.
copy-hash-table(ht)
Shallow copy ht.
defmacro!(name args &rest body)
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.
drop(n lst)
Drop n elements from the list.
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.
enable-hash-table-readernil

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.

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.
flatten(x)
Returns a list of all atoms present in the provided list. Of historical note, this was originally provided in Interlisp.
flip(fn y)
Given a function fn that takes arguments x and y, return a lambda with y applied to the function.
group(source n)
Group takes a list as input and produces a list of sublists of length n.
hash-table-to-alist(ht)
Converts the hash-table argument to an alist of (key . value) pairs.
hashkeys(ht)
Returns a list of the keys in a hash table.
iflet(bindings &body (then &optional else))
Evaluate bindings in a let form; if they are all T, execute the then form. Otherwise, execute the else form.
iflet*(bindings &body (then &optional else))
Evaluate bindings in a let* form; if they are all T, execute the then form. Otherwise, execute the else form.
in(obj seq &key (test (function eql)) key deep)

Returns T if obj, is in seq.

If seq is a list, test is used to determine whether the object matches. If key is not NIL, it is applied to elements before test. If deep is true, seq will be flattened before checking the list.

If seq is a vector, test is used to determine whether the object matches. If key is not NIL, it is applied to elements before test.

If seq is a hash table, test does not apply; the hash table's test is used. If key is not NIL, it is applied to obj before looking it up.

interpose(x sep)
Takes a list and a separator, and places separator between element of the list.
macroexpand-n(n form)
Expand the macro n times.
mapv(fn &rest vecs)
Utility to map fn over the vectors vecs, producing a vector.
mkkw(&rest args)
Create a keyword from its arguments.
mkstr(&rest args)
Concatenates its symbols and returns the printable representation of the result.
mksymb(&rest args)
Create a symbol from arguments, upcasing strings as required.
new-hash-tablenil
Create a new hash table with the #'equal function as its test.
new-vectornil
Create a new, empty, adjustable vector with fill pointer.
orlet(bindings &body body)
For each set of bindings, evaluate them in sequence. If each binding evaluates to T, evaluate body in a progn.
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.
sethash(k v ht)
Convenience notation for setting a value in a hash table.
symb(&rest args)
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.
take(n lst)
Take n elements from lst.
unlesslet(bindings &body body)
Evaluate the bindings in a let form; if they don't all evaluate to T, evaluate body in an implicit progn.
unlesslet*(bindings &body body)
Evaluate bindings in a let* form; if they are all not NIL, evaluate body, which is wrapped in an implicit progn.
whenlet(bindings &body body)
Evaluate the bindings in a let form; if they all evaluate to T, evaluate body in an implicit progn.
whenlet*(bindings &body body)
Evaluate bindings in a let* form; if they all evaluate to T, evaluate body, which is wrapped in an implicit progn.
with-gensyms(syms &body body)
Binds a whole list of variables to gensyms.
with-new-hash-table(htsyms &body body)
Create and bind a new hash table for each of the symbols in htsyms, executing inside a let form, and returns the hash table(s). If only one hash table is provided, return it as a single element; otherwise, return an alist of the symbol names and hash tables.
with-read-from-file((stream path &rest args &key (direction input directionp) &allow-other-keys) &body body)
Open path for reading, bound to stream, with any remaining arguments passed to with-open-file, and execute body.
with-write-to-file((stream path &rest args &key (direction output directionp) &allow-other-keys) &body body)
Evaluate body with the file at path opened and bound to the value of stream. Any remaining keyword arguments are passed to with-open-file.
zip(&rest lsts)
Zip together elements from each list. For example,
* (zip '(a b c) '(1 2 3))
'((a 1)(b 2)(c 3)).

The following functions cannot be automatically documented by Codex, as they are defined using the defmacro! macro. Their description is in the "Macro" section.

kutils-mop

list-all-slots(class-sym &optional (package *package*))
Given a class symbol (and optionally a package to search in), return a list of all the slots in an instance of that class.
make-instance-from-hash-table(class-type table &optional (package *package*) snake-case)
Given a class symbol and a hash table, attempt to build an instance from it. The instance initargs are derived from the slot definitions, and an attempt is made to pair the slot with a string derivation. It is expected that the hash table keys will be downcase. If snake-case is t, the keys should use hyphens; otherwise, they should use underscores. The slot type is used to determine whether to attempt to parse another object as a hash table entry.

kutils-system

path-as-string(path)
Given path, which can be either a string or pathname, return it as a string.
path-as-pathname(path)
Given path, which can be either a string or pathname, return it as a pathname.
extension-matches(path ext)
Returns t if path has the extensions ext. It is intended to be used in building predicates.
any-extension-matches(path extensions)
A predicate that returns T if path has any of the extensions provided.
filter-extensions(extensions path-list)
Given a list of paths in path-list, remove with an extension contained in extensions.
select-extensions(extensions path-list)
Given a list of paths in path-list, return a list of all paths with extensions contained in extensions.