API Reference


No packages.


Simple binary-tree implementation, not meant for high-performance code.


  • Function NODE-LEAF-P (node)
  • Function NODE-VALUE (tree)
  • Function NODE-LEFT-CHILD (tree)
  • Function NODE-RIGHT-CHILD (tree)
  • Function MAKE-BALANCED-TREE (list &key key sorted (comparison #'<) (test #'equal))
  • Function BREF (tree val &key (key #'identity))
    Returns a cons pair of node values which form the most constraining interval around val using key.
  • Function INTERPOLATE-FN (alist &key overflow-val underflow-val)
    Returns a function which interpolates the alist of points. Default overflow and underflow behavior is to return the last value present in the alist in that direction. Set overflow-val or underflow-val to a value or a function to allow specification of the out-of-bounds behavior.


A few numerical and/or symbolic calculus functions.


  • Function DIFF (fn &key (prec 1.d-9))
    Returns the one-sided numerical derivative of a function.
  • Function NEWTON (fn guess &key (value 0) (maxtries 50) (prec 1.d-4) (diff-prec 1.d-9))
    1-D Newton's method for solving an equation. If the method converges, returns the values of x_sol, fn(x_sol), and the number of iterations it took to converge. If the method does not converge, returns the values of nil and the number of iterations on failure. value is the value that fn should evaluate to. maxtries is the maximum number of iterations to attempt a solution. prec is the precision in the residue, below which convergence is assumed. diff-prec is the precision to use in calculating the derivative of fn via diff.
  • Function INVERT (fn &key (guess-fn (constantly 1)) (newton-prec 1.d-4) (diff-prec 1.d-9))
    Inverts a function numerically using Newton's method. Returns the inverse function using the precision parameters given. guess-fn is a function which evaluates to a guess value for each input value to the inverse function to use in Newton's method. newton-prec is the precision argument to give to Newton's method for the precision in the residue of the result. diff-prec is the precision to give to diff during Newton's method.


clos-utils provides various lacking utilities for working with structures and CLOS class instances as well as utilities for transforming them into clists which can be written/read with standard stream objects portably.


  • Function SLOT-NAMES (obj)
    Returns the list of slot symbols for a structure/CLOS class instance.
  • Function SLOT-KEYWORD-NAMES (obj)
  • Function SLOT-VALUES (obj)
    Returns a list of the slot values in a structure/CLOS class instance.
  • Function CLIST-TYPE (clist)
    Returns the type symbol for the type of the object the clist represents.
  • Function CLIST-FIELD-SYMBOLS (clist)
    Returns the field symbols for the object the clist represents.
  • Function CLIST-FIELD-VALUES (clist)
  • Function OBJECT->CLIST (obj)
    Returns a clist for the object obj. Supports structures/CLOS classes, arbitrary cons structures, nested sequences of any structure; all other objects are returned as-is.
  • Function OBJECT->PLIST (obj)
    Returns a plist for the object obj.
  • Function CLIST->OBJECT (clist)
    Currently only works for one-level-deep clists; needs to be fixed to allow arbitrary depth.
  • Generic-Function TYPE-CONSTRUCTOR (object)
    Returns the function responsible for constructing objects of the same type as the object. Default value is nil unless a method is defined for an object/type.
  • Method TYPE-CONSTRUCTOR (obj)
  • Method TYPE-CONSTRUCTOR (obj)
  • Method TYPE-CONSTRUCTOR (obj)


Used to access tables which have been pivoted so that a rows values are stratified across all rows, and a column's values are accessible all from a single row.


  • Function PIVOT (table create-table-fn open-table-fn)
    Pivot a table so that column values are accessible via rows. CREATE-TABLE-FN should create the table of type, and open-table-fn should open the same table again for reuse.
    ROW-INDEX   Accessor: ROW-INDEX


No packages.


No packages.


Various utilities for working with files


  • Function READ-LINES-FROM-FILE (file)
  • Function READ-LINES-FROM-PATHNAME (pathname)
  • Function READ-FIELDS-FROM-FILE (file)
  • Function READ-FIELDS-FROM-PATHNAME (pathname)
  • Function WRITE-LINES-TO-FILE (lines file)
  • Function WRITE-LINES-TO-PATHNAME (lines pathname &key if-exists if-does-not-exist)
  • Function FILE-LAST-CHANGED (pathname-or-string)
    Returns time in seconds since epoch of when the file data was changed.
  • Function SHA1 (string)
    Returns the sha1 sum of a string of text.
  • Function SHA1-FROM-PATHNAME (pathname-or-string)
    Returns sha1 sum of file located at pathname-or-string.


No packages.


Utilities for doing functional programming not already provided by Alexandria.


  • Function FLIP (f)
    Takes a function of two parameters and creates a new function which takes the same parameters in reverse order; particularly useful in conjunction with reduce.
  • Function SPLICE (xsplit fn1 fn2)
    Splices two functions togother at xsplit. If either function is nil, returns the other function or nil if both are nil.
  • Function TO-PAIR-FUNCTION (f)
    Makes f apply to a pair instead of two arguments
  • Function LFUNCALL (fn &rest args)
    Applies a function which takes a single list argument to an arbitrary number of arguments.
  • Function MIN-BY (x y &key (key #'identity))
  • Function MINIMUM (xs &key (key #'identity))
  • Function MAX-BY (x y &key (key #'identity))
  • Function MAXIMUM (xs &key (key #'identity))
  • Function ITERATE (fn initial count)
    Calls a function on its own result for count iterations. Returns the final result.
  • Function ITERATE-COLLECT (fn initial count)
    Calls a function on its own result for count iterations. Returns the full list of results.
  • Function SAFE-FUNCALL (key-args &rest args)
    Only calls a function when it is in fact a function, and returns all other objects.


Provides generic versions of (most ATM) the standard Common Lisp math functions; this allows easy extension to new mathematical objects.


  • Function USE-GMATH (package)
    shadowing-imports all the exported symbols from gmath into the current package
  • Variable *GMATH-GENERIC-MAP*
    (make-hash-table :test 'equal)
    Hash table mapping generic function symbols to the argument specification for the function.
  • Macro DEFMATH (fname (&rest args) &body body)
    Defines a generic function for use in generic-math. Necessary to allow for programmatically generated methods of certain mathematical types. Can use body just like with defgeneric to specify methods etc.
  • Macro DEFMETHOD-COMMUTATIVE (method-name (left-arg right-arg) &body body)
  • Macro INCF (place &optional (delta 1))
  • Macro DECF (place &optional (delta 1))
  • Function + (&rest xs)
  • Function SUM (xs)
    Convenience function for summing a list of values (it's reducing + across them).
  • Function PRODUCT (xs)
    Convenience function for multiplying a list of values
  • Generic-Function ADD (x y)
    Binary addition function
  • Function - (&rest xs)
  • Generic-Function SUB (x y)
    Binary subtraction function
  • Generic-Function UNARY-SUB (x)
    Unary subtraction function.
  • Function * (&rest xs)
  • Generic-Function MULT (x y)
    Binary multiplication function
  • Function / (&rest xs)
  • Function PROTECTED-/ (&rest xs)
  • Generic-Function DIV (x y)
    Binary division function
  • Generic-Function UNARY-DIV (x)
    Unary division function. Also known as multiplicative inversion.
  • Generic-Function PROTECTED-DIV (x y &key protected-value)
    Binary division protected from division by zero; returns protected-value whenever y is zero
  • Method PROTECTED-DIV (x y &key (protected-value 0))
  • Method PROTECTED-DIV (x y &key (protected-value 0))
  • Method PROTECTED-DIV (x y &key (protected-value 0))
  • Generic-Function PROTECTED-UNARY-DIV (x &key protected-value)
    Protected unary division function. Returns protected-value whenever x is zero.
  • Method PROTECTED-UNARY-DIV (x &key (protected-value 0))
  • Method PROTECTED-UNARY-DIV (x &key (protected-value 0))
  • Method PROTECTED-UNARY-DIV (x &key (protected-value 0))
  • Generic-Function SQRT (x)
    Square root function
  • Generic-Function EXPT (x y)
    Raises x to the y power
  • Generic-Function EXP (x)
  • Generic-Function LOG (x)
    Natural logarithm function
  • Generic-Function SIN (x)
    Sine, in radians
  • Generic-Function COS (x)
    Cosine, in radians
  • Generic-Function TAN (x)
    Tangent, in radians
  • Generic-Function SEC (x)
    Secant, in radians
  • Method SEC (x)
  • Method SEC (x)
  • Method SEC (x)
  • Generic-Function CSC (x)
    Cosecant, in radians
  • Method CSC (x)
  • Method CSC (x)
  • Method CSC (x)
  • Generic-Function COT (x)
    Cotangent, in radians
  • Method COT (x)
  • Method COT (x)
  • Method COT (x)
  • Generic-Function SINH (x)
    Hyperbolic sine function
  • Generic-Function COSH (x)
    Hyperbolic cosine function
  • Generic-Function TANH (x)
    Hyperbolic tangent function
  • Generic-Function SECH (x)
    Hyperbolic secant function
  • Method SECH (x)
  • Method SECH (x)
  • Method SECH (x)
  • Generic-Function CSCH (x)
    Hyperbolic cosecant function
  • Method CSCH (x)
  • Method CSCH (x)
  • Method CSCH (x)
  • Generic-Function COTH (x)
    Hyperbolic cotangent function
  • Method COTH (x)
  • Method COTH (x)
  • Method COTH (x)
  • Method ADD ((x number) (y number))
  • Method SUB ((x number) (y number))
  • Method UNARY-SUB ((x number))
  • Method MULT ((x number) (y number))
  • Method DIV ((x number) (y number))
  • Method UNARY-DIV ((x number))
  • Method PROTECTED-DIV (x (y number) &key (protected-value 0))
  • Method PROTECTED-UNARY-DIV ((x number) &key (protected-value 0))
  • Method SQRT ((x number))
  • Method EXPT ((x number) (y number))
  • Method EXP ((x number))
  • Method LOG ((x number))
  • Method SIN ((x number))
  • Method COS ((x number))
  • Method TAN ((x number))
  • Method SINH ((x number))
  • Method COSH ((x number))
  • Method TANH ((x number))


Interface for spawning & communicating with gnuplot sessions from LISP.


  • Function GNUPLOT-INIT
  • Function GNUPLOT-CLOSE (session)
  • Function GNUPLOT-CMD (session command-string)


Functions for interfacing with GSL which don't seem to work/aren't currently provided through GSLL.


  • Variable +GSL-EOF+
    End-of-file return value for gsl functions


Utilities for working with hash tables


  • Function HASH-TABLE->ALIST (hash-table)
  • Function HASH-KEYS (hash-table)
  • Function HASH-VALUES (hash-table)
  • Function HMAP (fn hash-table)
    hmap is a more functional version of maphash; instead of returning nil and relying on mutable state, hmap returns a new hash table with the same keys but mapped values in the resulting hash table. fn is a function which takes a key and value from hash-table and returns an updated value for the resulting hash table.
  • Function ALIST->HASH-TABLE (alist &optional (test 'eql))


HDF5 cffi bindings


  • Cffi-Type SIZE-T
  • Cffi-Type HID-T
  • Cffi-Type HERR-T
  • Cffi-Type HSIZE-T
  • Cffi-Type HSSIZE-T
  • Cffi-Enum H5T-CLASS-T
  • Cffi-Enum H5T-DIRECTION-T
  • Cffi-Enum H5S-SELOPER-T
  • Variable +H5S-UNLIMITED+
  • Variable +H5S-ALL+
  • Variable +H5F-ACC-TRUNC+
  • Variable +H5F-ACC-RDONLY+
  • Variable +H5F-ACC-RDWR+
  • Variable +H5P-DEFAULT+
  • Variable +H5P-DATASET-CREATE+
  • Variable +H5T-NATIVE-CHAR+
  • Variable +H5T-NATIVE-UCHAR+
  • Variable +H5T-NATIVE-SHORT+
  • Variable +H5T-NATIVE-USHORT+
  • Variable +H5T-NATIVE-INT+
  • Variable +H5T-NATIVE-UINT+
  • Variable +H5T-NATIVE-LONG+
  • Variable +H5T-NATIVE-ULONG+
  • Variable +H5T-NATIVE-LLONG+
  • Variable +H5T-NATIVE-ULLONG+
  • Variable +H5T-NATIVE-FLOAT+
  • Variable +H5T-NATIVE-DOUBLE+
  • Variable +H5T-COMPOUND+
  • Variable +H5F-OBJ-FILE+
  • Variable +H5F-OBJ-DATASET+
  • Variable +H5F-OBJ-GROUP+
  • Variable +H5F-OBJ-DATATYPE+
  • Variable +H5F-OBJ-ATTR+
  • Variable +H5F-OBJ-ALL+
  • Variable *HDF-CFFI-TYPE-MAP*
    (list (cons cl-ana.hdf-cffi:+h5t-native-char+ :char)
          (cons cl-ana.hdf-cffi:+h5t-native-uchar+ :uchar)
          (cons cl-ana.hdf-cffi:+h5t-native-short+ :short)
          (cons cl-ana.hdf-cffi:+h5t-native-ushort+ :ushort)
          (cons cl-ana.hdf-cffi:+h5t-native-int+ :int)
          (cons cl-ana.hdf-cffi:+h5t-native-uint+ :uint)
          (cons cl-ana.hdf-cffi:+h5t-native-llong+ :long-long)
          (cons cl-ana.hdf-cffi:+h5t-native-ullong+ :ullong)
          (cons cl-ana.hdf-cffi:+h5t-native-float+ :float)
          (cons cl-ana.hdf-cffi:+h5t-native-double+ :double))
  • Function CFFI-NATIVE-TYPE (hdf-native-type)
  • Function HDF-NATIVE-TYPE (cffi-native-type)


Table subclass specializing on HDF5 datasets


    buffer size in number of rows
    index to the in-memory chunk
    Object for storing a row to be read from/written to hdf table. It's stored as part of the table for efficiency purposes and should not be handled directly by the user; use the awesome higher level tools for that.
    Index to the row in the buffer which is currently being modified prior to writing.
    hdf dataset which the table is reading from/writing to.
    hdf type for the row data object
    Index to row which should be sequentually read next
    number of rows in hdf-table
  • Function OPEN-HDF-TABLE (hdf-file dataset-name &key buffer-size)
  • Function CREATE-HDF-TABLE (hdf-file dataset-path names-specs &key (buffer-size 1000))
    Creates a hdf-table for writing in hdf-file with dataset-path as the path to the dataset in the hdf-file and the alist names-specs which maps the field names to their typespecs (this is just applying rest to the typespec for the table). Buffer size will be used as both the chunksize for the hdf dataset and as the size of the buffer for writing into the file.
    Path to dataset within each file. The path should be uniform if the hdf files truly are a chain.
    The in-memory hdf-table
    hdf-file currently opened by the active hdf-table.
    List of file-paths which contain one hdf-table each
    Length (in indices) of each table
    Start indexes for each table
    index for in-memory hdf-table in (virtual) list of tables
    starting row index for the current table
    last row index for the current table
    binary search tree storing the indeces for efficient searching
    Index to row which should be sequentually read next
    number of rows in hdf-table
  • Function OPEN-HDF-TABLE-CHAIN (filename-list dataset-path)
    Creates and initializes hdf-table-chain given the filename-list and dataset-path


Utilities for creating/reading HDF5 types from/into typespecs.


  • Function TYPESPEC->HDF-TYPE (&rest xs3)
  • Function HDF-TYPE->TYPESPEC (&rest xs135)


Utilities for a more lispy interface to HDF5


  • Macro WITH-CLEANUP ((&rest specs) &body body)
    Executes body inside of a lexical environment where objects described by specs are bound and then freed upon concluding the body. Each spec is a list of 3 elements: 1. A symbol which will denote a variable inside the body, 2. A form which will be evaluated and its value bound to the symbol, 3. A function for cleaning up the object referenced by the symbol; it will be given the symbol as the sole argument.
  • Macro WITH-OPEN-DATASPACE ((dataspace dataset) &body body)
    Safely work with dataspace taken from dataset
  • Macro WITH-CREATE-DATASPACE ((dataspace rank dims maxdims) &body body)
    Creates a new dataspace and cleans up after it
  • Macro WITH-DATASET-TYPE ((type dataset) &body body)
  • Function OPEN-HDF-FILE (filename &key direction (if-exists nil if-exists-supplied-p) (if-does-not-exist nil if-does-not-exist-supplied-p) (read-access-parameters +h5p-default+) (write-access-parameters (list +h5p-default+ +h5p-default+)))
    Opens an hdf file, returning a handle to the file (hid-t). direction can be :input or :output. if-exists can be :supersede :error nil if-does-not-exist can be :create :error nil
  • Function CLOSE-HDF-FILE (hdf-file)
    Closes all datatype objects associated with file along with the file
  • Macro WITH-OPEN-HDF-FILE ((hdf-file file-path-or-string &key direction (if-exists nil if-exists-supplied-p) (if-does-not-exist nil if-does-not-exist-supplied-p) (read-access-parameters +h5p-default+) (write-access-parameters (list +h5p-default+ +h5p-default+))) &body body)
    Macro providing lispy access to hdf (HDF5) files. Use just like you would with-open-file, just give a file and a path/string. The usual key arguments for access mode, etc. are honored and transformed into HDF5 terms. The argument hdf-file is the symbol you'll use to refer to the file handle inside of the macro body.
  • Function HDF-MKGROUP (file group-name)
    Creates a group with name group-name in hdf-file file; returns path to group with final '/' included.


No packages.

For some reason my SBCL doesn't support int-char anymore, so here it is.


  • Function INT-CHAR (integer)


No packages.


Utilities for working with lists not already provided by Alexandria.


  • Function RANGE (start end &optional (step 1))
  • Function ZIP (x y)
  • Function LZIP (&rest lists)
    Like zip, but uses lists instead of cons pairs thus allowing ntuples
  • Function UNZIP (xs)
    Returns a cons with the car being the cars of the zipped xs and the cdr being the cdrs.
  • Function UNLZIP (xs)
    lzip is an inverse (through apply) of itself, simply applies lzip to its argument, returning a list of the previously zipped lists in xs.
  • Function MAPZIP (fn &rest lists)
    Returns an alist mapping the list of corresponding elements from each input list to the value of fn for those values; it's just zipping together the arguments with the value of fn. If only one list is given, the elements are mapped directly (i.e. not in a list)
  • Function TREE-MAP (fn &rest trees)
    Maps function over identically structured trees (lists)
  • Function INTERSPERSE (obj lst)
    Inserts obj in between each pair of elements in lst
  • Function TRANSPOSE (xs)
  • Function CARTESIAN-PRODUCT (&rest xs)
  • Function EVERY-NTH (list n &optional (start 0))
  • Function EXCEPT-NTH (x n)
  • Function AT-INDICES (lst indices)
    Returns the values from lst located at positions given by indices
  • Function EXCEPT-AT (xs ns &key (test #'eql) uniquely-sorted)
    Yields the list of xs except for the elements at the positions in ns. Set uniquely-sorted to t if you want except-at to assume the ns are already unique and sorted least to greatest.
  • Function COMPRESS (list &key (key #'identity) (test 'eql) sort-by singleton-pairs)
    Compress list such that duplicate elements are combined into a single pair entry which has as the car the element value and as the cdr the count. The singleton-pairs option controls whether single elements are still placed inside a pair. This is useful when the elements of the list you wish to compress are cons cells, as this would otherwise lead to ambiguity in the result.
  • Function LIST-LESS-THAN (list1 list2)
  • Function LIST-GREATER-THAN (list1 list2)
  • Function AREF-BY-LIST (array indexlist)
    Access array element via index list instead of individual indices
  • Function MAKE-OFFSETS (sizes)
    Takes a list of sizes and returns a list containing 0, (first sizes), (+ (first sizes) (second sizes)), ... summing the sizes as the list goes. This pattern has turned out to be recurrent, and the result can be interpreted as finding the starting index of the ith list in the concatenation of n lists.
  • Function CDRS (xs)
  • Function CARS (xs)
  • Function LIST->SET (list &optional (test #'eql))
    Returns list with duplicates removed
  • Function PARTITION (list &key (key #'identity) (test #'eql))
    Re-groups the contents of a list into partitions using the test function provided. Guarantees that the elements of each group pass test with every member of the partition as long as the test function is transitive. Does not necessarily preserve order of partitions, but preserves order of the elements relative to each partition. This function supports two different conceptual approaches to partitioning: * By relation: the test function is the equivalence relation operator * By association: using a key function which maps into a set of index values allows the user to partition according to association with that value.
  • Function TREE-FLATTEN (tree)
    Collects all non-nil atoms in a tree and returns the list of them as encountered during a depth-first search.
  • Function LENGTH-EQUAL (list length)
    Returns t/nil as soon as it is apparent that the list does not contain exactly length elements.
  • Function SINGLE (list)
    Checks to see if list is a list with exactly one element.
  • Function APPEND1 (list object)
    Creates a list containing object and appends list to it.
  • Function CONC1 (list object)
    Like append1, but uses nconc instead of append
  • Function MKLIST (object)
    Ensures that object is a list, if not object is packaged in a list.
  • Macro ENSURE-LISTS ((&rest list-bindings) &body body)
    Ensures and rebinds variables as lists via mklist. Each list-binding must be either a symbol or a list (symbol form); for a symbol it will be bound to (mklist symbol) in the body; for a list the first element of the list-binding will be bound to (mklist (second list-binding)).
  • Function LONGER (x y)
    Efficiently compares two lists, or if they're not both lists simply calls length on each and compares. This could be sped up a bit if one argument is a list and the other not, so it's a work in progress.
  • Function GROUP (source n)
    Takes a list and returns a list of lists of the elements in the list grouped in lists of size n with the remainder in the last list.
  • Function PRUNE (test tree)
    Like remove-if, but for lists treated as trees.
  • Function FIND2 (fn list)
    Like find, but it returns two values: the list element and the value that fn returned.
  • Function BEFORE (x y list &key (test #'eql))
    Tells you if x is found before y in list.
  • Function AFTER (x y list &key (test #'eql))
    Tells you if x is found after y in list.
  • Function DUPLICATE (object list &key (test #'eql))
    Tells you if the object occurs more than once in the list.
  • Function PERMUTE (list permutation)
    Re-arranges the elements in list according to the permutation.
  • Function PLIST->ALIST (plist)
    Forms an alist from a plist
  • Function ALIST->PLIST (alist)
    Forms a plist from an alist
  • Function PLIST-SELECT-FIELDS (plist &rest fields)
    Returns a list of the fields from plist in the order specified; the element will be nil if the field is not present.
  • Macro DO-PLIST ((field-symbol field-value plist) &body body)
    Executes body via looping over plist, binding each field symbol to field-symbol and each field value to field-value. Returns nil.
  • Macro DO-PLISTS (plists &body body)
    Loops over a plist, binding each field in the plist to a variable of the same name as the field symbol but in the current package.


No packages.


Basic macro utilities


  • Macro DEFPLURAL (fname)
    Defines a function which maps the function with symbol fname across a list. The defined function has as its symbol fname with a trailing s character appended.
  • Macro MAP-BIND (fn symbols &body body)
    Binds each symbol in symbols to the value of (funcall fn symbol) and executes body inside of this lexical scope.
  • Macro ABBREV (short long)
    Defines abbreviated operator with name short expanding to a call to long.
  • Macro ABBREVS (&rest names)
    Defines multiple abbreviations simultaneously. Arguments are interpreted as: (abbrevs short1 long1 short2 long2 ...)
  • Macro DBIND (&rest args)
  • Macro MVBIND (&rest args)
  • Macro MVSETQ (&rest args)
  • Macro FVBIND (&rest args)
  • Macro POLL (test wait &body body)
    Repeatedly executes test form; if test returns true, executes body; otherwise waits for wait seconds and tries again. Returns last form in body.
  • Macro INRANGE (xlo op1 x op2 xhi &key (prec 0))
  • Macro CASE-EQUAL (form &body cases)
  • Macro COND-SETF (place value &optional (condition t))
    Only sets the place when the condition is met. condition may be one of three values: :place, :value, or :both. :place specifies that the place must evaluate to a non-nil value, :value specifies that the value must evaluate to a non-nil value, and :both specifies that both place and value must evaluate to non-nil values.
  • Macro PRINT-EVAL (arg)
  • Macro WITH-DEFAULT-ARGS (fn (&rest argbindings) &body body)
    Executes body with default argument values supplied to fn in a convenient way. fn is either the name of a function or a list (function local-name); fn is defined via flet and takes no arguments, but refers to the arguments in argbindings. argbindings are used analogously to let. Example: (with-default-args (list fn) ((x 3)) (fn)) yields (3). More useful examples would involve conditionally setting argument values in the body.
  • Macro WHEN-KEYWORDS (&body keyword-arg-specs)
    Creates a plist containing the keyword arguments only when the values are non-nil; if a keyword-arg-spec is a list, then the first element is taken to be the field symbol and the second element the expression to be passed as the value.
  • Macro DEFUN-WITH-SETF (fname (&rest lambda-list) &body body)
    Defines function along with setfable version when body is a single expression; throws error otherwise. This is limited to cases where the expression is already understandable to setf.
  • Function SYMB (&rest args)
  • Macro ALAMBDA (parms &body body)
  • Macro AIF (test then &optional else)
  • Macro AWHEN (test &body body)
  • Macro TIME-PROC (&body body)
    Times the execution of body and returns multiple values: 1. Real time in seconds, 2. Run time in seconds, and the rest being the return values of body.
  • Function LAMBDA-LIST-CALL-FORM (fname lambda-list)
    Returns the appropriate lambda-list call form for a function named fname and a lambda-list given by lambda-list. Macros are more difficult since lambda lists can have nested structure, so I'm only considering function lambda lists for now. This still works for macros which have this limited sort of lambda list however. One issue that is not currently resolved is supplying arguments which have a -supplied-p argument. Functions can be handled, but not in the same way as macros (since apply does not work). Also: &rest is handled only for functions becuause, again, there is no practical way to use this method for macros.
  • Macro SUPPRESS-OUTPUT (&body body)
    suppress-output redirects all output to /dev/null, thus silencing any messages printed to *standard-output*.
  • Macro KLAMBDA ((&rest key-args) &body body)
    Modified lambda which returns a keyword arg-accepting function with &allow-other-keys
  • Macro OLET ((&rest bindings) &body body)
    olet (at the moment) functions much like let*, except that each binding is only evaluated once at most, and not at all if the lexical binding is never used in the body. This can result in a tremendous speedup when used in creating context, e.g. looping over a table but only needing a few fields from the table. In test cases the compiler appeared to remove unused bindings entirely thanks to the symbol-macrolet.
  • Macro DLAMBDA (&rest ds)


No packages.


No packages.


No packages.


No packages.


No packages.


No packages.


No packages.


No packages.

Defines generic functions for working with/converting things which behave like maps (in the mathematical sense), e.g. hash tables, alists, etc.


  • Generic-Function MAP->ALIST (object)
    Returns the values of a data-source as an alist mapping the independent value to the dependent one. Multidimensional independent variable data can be represented as a list of values.
  • Method MAP->ALIST ((obj hash-table))
  • Method MAP->ALIST ((obj hash-table))
  • Method MAP->ALIST ((obj hash-table))
  • Function MAP->HASH-TABLE (object &optional test)


No packages.


Provides memoized functions (only compute for new arguments, otherwise lookup in a hash table)


  • Function GET-MEMO-MAP (memo-fn)
    Returns the memoized function's value hash table.
  • Function RESET-MEMO-MAP (memo-fn)
    Resets the memoization hash table for memo-fn
  • Macro MEMOIZE (fn &key (test 'equal))
    Macro for memoizing any function; test argument allows you to specify how arguments will be looked up.
  • Macro MEMOLET (memo-fns &body body)
    A macro for defining mutually recursive memoized functions and executing body with knowledge of them. Cannot access the lookup tables via *memoized-map* in the body, since this would prevent garbage collection of the memoized function hash tables.
  • Function UNMEMOIZE (fn)
    Removes fn from the memoization lookup table; this prevents access to the lookup map from outside the function but allows the function to be garbage collected if necessary.
  • Macro DEFUN-MEMOIZED (function-name arg-list &body body)
    Macro for defining a memoized function. Note that currently there is a small inconvenience in that lambda-lists are not automatically added to the documentation used by things like SLIME.


No packages.


Provides various utilities for using packages as well as the abstraction of a package group


  • Function SHADOWING-USE-PACKAGE (from-package &optional to-package)
    shadowing-imports all the exported symbols from gmath into the current package
  • Function ADD-PACKAGE-TO-GROUP (package group)
    Adds the package to the package group given by group.
  • Macro DEFPACKAGE-IN-GROUP (package-name group &body package-body)
    Defines a package while placing this package into the group specified by group. group can technically be any object, but I like to stick to keyword symbols. Any package statements can be used in the package-body portion.
  • Function USE-PACKAGE-GROUP (group &optional dest-package)
    Calls shadowing-use-package on each package in group and either the current package or dest-package.


Utilities for working with pathnames


  • Function PATHNAME-ABSOLUTE-P (pathname-or-string)
  • Function PATHNAME-RELATIVE-P (pathname-or-string)
  • Function ->ABSOLUTE-PATHNAME (pathname-or-string)
  • Function DIRECTORY-PATHNAME-P (pathname-or-string)
    Returns t iff pathname-or-string refers to a directory
  • Function MKDIRPATH (pathname-or-string)
    Returns a path which always refers to a directory (platform independent)
  • Function BASENAME (pathname)
    Returns basename of pathname; pathname-name strips the extension while this utility function preserves it.
  • Function SUBPATH (directory path-or-format-recipe &rest args)
    Returns namestring for a path under directory. path-or-format-recipe can be a pathname directly, in which case the rest of the arguments are unused. Or, it can be a format string which when format is supplied with both the recipe and the rest of the arguments should return a namestring for a valid pathname. In either case, ensure-directories-exist will be called to ensure that the path is ready for use. If for whatever reason subpath is given an absolute pathname, it will be returned as-is. If the result of a format processing a format string and the rest of the arguments is an absolute pathname, this will be returned.


No packages.


No packages.


Table wrapper for reading which automatically re-loads table for reading after fully reading the contents (not guarranteed by the raw table types).


    Function which creates the table being wrapped.
    Lisp form which returns the table opener function when evaluated. A table opener An optional field which assists in serializing reusable tables.
    The table which is being wrapped.
    Boolean which tells the wrapper when it needs to close and re-open the table.
  • Function MAKE-REUSABLE-TABLE (creation-fn &optional opener-form)
    Returns result of creation-fn if reusable-table, else returns reusable-table which will make use of creation-fn to generate new copies when needed.
  • Macro WRAP-FOR-REUSE (table-creation-form &optional opener-form)
    Creates a reusable (when table-creation-from does not return a reusable-table) table which places the table-creation-form into a closure which will be evaluated each time the table gets re-read from the beginning. If the creation form returns a reusable-table, simply returns the table.


No packages.


No packages.


No packages.


String utilities not already provided by Alexandria


  • Function LISPIFY (symbol-or-string)
    Converts symbol or string into a string and replaces all spaces and underscores with -, and convert to uppercase.
  • Function STRING-APPEND (&rest strings)
  • Function LINES (string)
    Splits a string into a list of the lines comprising the string.
  • Function UNLINES (lines &optional (trailing-newline-p t))
    Joins a list of lines into original string, with optional trailing newline.
  • Function WORDS (string)
    Returns the read words (symbols, numbers, etc.) contained in a string
  • Function MKSTR (&rest args)


Basic utilities for working with symbols


  • Function KEYWORDIFY (symbol-or-string)
    Returns the keyword version of a symbol or string.
  • Function KEYSYMB (args)
    Returns a keyword symbol formed by symbol versions of each element in args interspersed with hyphens (-).
  • Macro KEYSYMBQ (&rest args)
    Convenient macro for using keysymb; quotes the list of args and passes it to keysymb.


Table class; provides basic necessary interface for working with sets of data.


  • Class TABLE
    List of field names.
    :write for a writable table, :read for a readable table, and :both for a table which has no restriction on being written to or read from only. nil for a table which is not open.
  • Function TABLE-OPEN-P (table)
  • Function TABLE-FIELD-SYMBOLS (table)
  • Generic-Function TABLE-LOAD-NEXT-ROW (table)
    Loads the next row into the current row buffer. Returns nil if the next row does not exist/there is a read failure (which can be the same thing), non-nil otherwise.
  • Generic-Function TABLE-ACTIVATE-FIELDS (table field-names)
    Function for optimization based on which fields are to be read from the table; default method is to do nothing which works when these optimizations do nothing for a particular table type.
  • Method TABLE-ACTIVATE-FIELDS (table field-names)
  • Method TABLE-ACTIVATE-FIELDS (table field-names)
  • Method TABLE-ACTIVATE-FIELDS (table field-names)
  • Generic-Function TABLE-GET-FIELD (table field-symbol)
    Gets the field datum from the current row for field denoted by the field-symbol
  • Generic-Function TABLE-SET-FIELD (table field-symbol value)
    Sets the field value of the current output row
  • Generic-Function TABLE-COMMIT-ROW (table)
    Commits (writes) the current output row to the table
  • Macro TABLE-PUSH-FIELDS (table &body field-specs)
    Sets fields and commits row of table using field-specs. Each field-spec is either a symbol which represents both the field-symbol and the variable storing the field data.
  • Generic-Function TABLE-CLOSE (table)
    Close any open files, etc.
  • Method TABLE-CLOSE (table)
  • Method TABLE-CLOSE ((tab table))
  • Generic-Function TABLE-NROWS (table)
    When available, returns the number of rows stored in the table, otherwise returns nil.
  • Method TABLE-NROWS (table)
  • Method TABLE-NROWS (table)
  • Method TABLE-NROWS (table)
  • Function TABLE-REDUCE (table fields fn &key initial-value)
    table-reduce mimics reduce but with the modification that fn should take one more argument than the number of fields specified with the first argument used to store the state as fn is called across the table. table-reduce can be used as a functional/non-macro solution to looping over the table. fields is a list of field names/symbols. They will be passed in the order specified to fn. fn is function taking the computation state as the first argument and then each selected field as an argument in the order given in fields; can use the state argument to collect a list of values for example.
  • Macro DO-TABLE ((rowvar table) field-selections &body body)
    Macro for iterating over a table. rowvar is a symbol which will be bound to the row number inside the loop body. You can optionally use a list (rowtype rowvar) which will allow for the rowvar to have a type declared for it. table is the table which will be looped upon. To select specific fields from the table for reading, specify all the desired field names in field-selections; if field-selections is nil then all fields will be read. Note that it is still more efficient to specify all desired fields; for two field data this results in about a 16% running time difference. Also you must specify either none or all of the desired fields to work with during the loop body. Each field-selection is a list of 1. field names to access during the loop, by default the value will be bound to the lispified field name as a symbol, 2. A list containing a symbol as the first element and the field name as the second which will be bound to the symbol given as the first element of the list. The code body will be run for each row in the table. If fields are explicitly selected, then you can use declare statements at the beginning of the loop body; otherwise this is not supported.
  • Function OPEN-TABLE-CHAIN (creation-functions)
    Creates a chain of tables by running the appropriate creation-function when the previous table fails on table-load-next-row. Each creation function should be a function taking zero arguments and returning a table.
  • Function RESET-TABLE-CHAIN (table-chain)
    Resets the table counter in the chain so that it can be re-read.
  • Method TABLE-LOAD-NEXT-ROW ((table table-chain))
  • Method TABLE-GET-FIELD ((table table-chain) field-symbol)
  • Function OPEN-PLIST-TABLE (plists)
  • Method TABLE-LOAD-NEXT-ROW ((table plist-table))
  • Method TABLE-GET-FIELD ((table plist-table) field-symbol)
  • Method TABLE-CLOSE ((table plist-table))
  • Function CREATE-PLIST-TABLE (field-names)
  • Method TABLE-SET-FIELD ((tab plist-table) field-symbol value)
  • Method TABLE-COMMIT-ROW ((tab plist-table))
  • Method TABLE-NROWS ((tab plist-table))


No packages.


No packages.


tensor provides utilities for treating nested sequences as multidimensional arrays; integration into the generic math framework yields MATLAB/GNU Octave-style functionality with arrays, lists, etc.


  • Function SEQUENCEP (x)
  • Function MAKE-TENSOR (dimension-list &key (type 'vector) (initial-element 0.0d0))
    Creates a tensor with each dimension in dimension-list denoting the length of the sequence at that dimension with the type of the sequences given by the optional type argument.
  • Function FUNCTION->TENSOR (dimension-list fn &key (type 'vector))
  • Function TENSOR-REF (tensor &rest subscripts)
    References tensor via subscripts
  • Function TREF (tensor &rest subscripts)
    Abbreviation for tensor-ref; setfable.
  • Function TENSOR-FLAT-REF (tensor subscript)
    References tensor by single subscript; done in such a way to mimick the way multidimensional arrays are stored in memory by e.g. C. Assumes rectangular tensor.
  • Function TFREF (tensor subscript)
    Abbreviation for tensor-flat-ref; setfable.
  • Function (setf TENSOR-FLAT-REF) (value tensor subscript)
  • Function (setf TFREF) (value tensor subscript)
  • Function (setf TENSOR-REF) (value tensor &rest subscripts)
  • Function (setf TREF) (value tensor &rest subscripts)
  • Function TENSOR-RANK (tensor)
  • Function TENSOR-DIMENSIONS (tensor)
    Returns a list of the sizes of the tensor for each dimension.
  • Function TENSOR-MAP (fn &rest xs)
    Maps fn across xs for arbitrarily deep sequences. Treats non-sequences as sequences of arbitrary depth.
  • Function TENSOR-+ (&rest xs)
    Convenient nickname for mapping + over tensors.
  • Function TENSOR-- (&rest xs)
    Convenient nickname for mapping - over tensors.
  • Function TENSOR-* (&rest xs)
    Convenient nickname for mapping * over tensors.
  • Function TENSOR-/ (&rest xs)
    Convenient nickname for mapping / over tensors.
  • Function TENSOR-CONTRACT (tensor-index-pairs &key (type 'vector))
    Contracts each tensor along the dimension specified by the specified index, resulting in a tensor of recursively rectangular sequences of type type. Each tensor-index-pair is a cons with the car being the tensor to contract and the cdr being the index denoting the dimension to contract along for this tensor. It is just the mathematical notion of tensor contraction. Example: multiplying matrices: A . B ==> (tensor-contract (list (cons A 1) (cons B 0))) In words, contract tensors A and B along the second index of A and the first index of B.
  • Function TENSOR-FLATTEN (x)
    Returns a flattened tensor along with the dimensions of original tensor so that unflattening is possible.
  • Function TENSOR-UNFLATTEN (x dims)
    Restores a flattened tensor to its original dimensionality.


Table types which have typed columns. Provides automatic conversion between foreign and LISP objects.


    list of typespecs, one per field
    CFFI cstruct type designator for the row object
    pointer to foreign object storing current row information.
    Hash table which maps the field symbols to the lisp->c converter function for corresponding field.
    Hash table which maps the field symbols to the c->lisp converter function for corresponding field.
  • Function TYPESPEC->FIELD-NAMES (compound-typespec)
    Returns field names from the compound type designation.
  • Function TYPESPEC->FIELD-SPECS (compound-typespec)
    Returns field typespecs from the compound type designation.
  • Function TYPED-TABLE->TYPESPEC (table)
    Creates a typespec from the table


typespec provides a mechanism for referring to foreign or LISP datatypes as well as utilities for conversion between the two.


  • Function TYPESPEC->CFFI-TYPE (&rest xs3)
  • Function TYPESPEC-COMPOUND-P (typespec)
    Tests a typespec for being a compound typespec.
    Returns the alist mapping field name to typespec.
    Returns the field names for the compound type.
    Returns the typespecs for the fields in the compound type.
  • Function TYPESPEC-ARRAY-P (typespec)
    Tests a typespec for being an array typespec.
  • Function TYPESPEC-ARRAY-ELEMENT-TYPE (typespec)
    Returns the element type for the array type.
  • Function TYPESPEC-ARRAY-DIM-LIST (typespec)
    Returns the list of dimension sizes for the array type.
  • Function TYPESPEC-ARRAY-RANK (typespec)
    Returns the number of dimensions (rank) of the array type.
  • Function TYPESPEC-ARRAY-SIZE (typespec)
    Returns the total number of elements in the array type.
  • Function TYPESPEC-FLATTEN-ARRAYS (typespec)
    Flattens an array typespec if typespec is an array typespec, otherwise returns typespec unchanged. Note that this operation is recursive, in that if there are arrays in the typespec(s) of the component type(s), then they are flattened as well.
  • Function TYPESPEC-FOREIGN-ALLOC (typespec &optional (count 1))
    Allocates space for count foreign objects of type specified by typespec.
  • Function TYPESPEC->LISP-TO-C (typespec)
    Returns a function which takes 1. a lisp object, 2. a corresponding C pointer and sets the fields/values of the C object recursively. The pointer to the C-object is returned.
  • Function TYPESPEC->C-TO-LISP (typespec)
    Returns a function which takes a c-pointer argument and returns a lisp object containing the converted values.
  • Function CHAR-VECTOR->STRING (char-vector &optional length)
    Returns a string version of a vector of integers interpreted as the numerical codes for characters. If argument length is given, the result contains only the first length characters, or if length is longer than the char-vector, the char-vector interpreted into a string as if length were not given.