128 lines
4.4 KiB
HTML
128 lines
4.4 KiB
HTML
<?xml version="1.0"?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<title>KUTILS: Kyle's utilities</title>
|
|
<link rel="stylesheet" type="text/css" href="style.css"/>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="header">
|
|
<h1>KUTILS</h1>
|
|
<h2>Kyle's utility package for Common Lisp development</h2>
|
|
</div>
|
|
|
|
<h3>Introduction</h3>
|
|
|
|
<p>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.</p>
|
|
|
|
<p>The utilities can be categorised as</p>
|
|
|
|
<ul>
|
|
<li>Those from <strong>On Lisp</strong>,</li>
|
|
<li>Those from <strong>Let Over Lambda</strong>,</li>
|
|
<li>The <code>hash-table</code> functions,</li>
|
|
<li>Miscellanea</li>
|
|
</ul>
|
|
|
|
<h3>On Lisp</h3>
|
|
|
|
<ul>
|
|
<li><code>mkstr</code>: concatenates its symbols and returns the printable representation
|
|
of the result</li>
|
|
<li><code>symb</code>: passes its arguments to <code>mkstr</code>
|
|
to produce a printable representation, and returns the symbol built
|
|
from this result; if the symbol does not exist, it will be
|
|
created.</li>
|
|
<li><code>group</code>: takes a list as input and produces a
|
|
list of sublists of length n.</li>
|
|
<li><code>flatten</code>: Returns a list of all atoms present in
|
|
the provided list.</li>
|
|
<li><code>compose</code>: allows a number of functions with the same arity
|
|
to be composed together in a chain.</li>
|
|
</ul>
|
|
|
|
<h3>Let Over Lambda</h3>
|
|
|
|
<ul>
|
|
<li><code>defmacro!</code>: provides automatic gensyms and
|
|
once-only evaluation. Arguments that begin with g! will be
|
|
automatically <code>gensym</code>'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.
|
|
</ul>
|
|
|
|
<h3>hash-table functions</h3>
|
|
<ul>
|
|
<li><code>sethash</code>: convenience function for setting a value
|
|
in a hash table.</li>
|
|
<li><code>hashkeys</code>: returns a list of all the keys in a hash
|
|
table.</li>
|
|
<li><code>hash-table-to-alist</code>: converts the hash table to an
|
|
alist of <code>(key . value)</code> pairs.</li>
|
|
<li><code>alist-to-hash-table</code>: converts an alist to a hash
|
|
table.</li>
|
|
<li><code>enable-hash-table-reader</code>: enables the reader
|
|
macro <code>#{}#</code> for hash tables. The resulting hash-table
|
|
will use #'equal for equality. For example,
|
|
|
|
<pre>
|
|
#{:a :b :c :d}#
|
|
</pre>
|
|
|
|
will create a hash-table with the keys <code>:a</code>
|
|
and <code>:c</code>. <code>:a</code> stores the value <code>:b</code>,
|
|
and <code>:c</code> stores the value <code>:d</code>.</li>
|
|
</ul>
|
|
|
|
<h3>Miscellaneous</h3>
|
|
<ul>
|
|
<li><code>interpose</code>: places a separator between each element
|
|
of a list.</li>
|
|
<li><code>build-list</code>: 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.</li>
|
|
<li><code>partial</code>: 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.</li>
|
|
<li><code>macroexpand-n</code>: expand the macro n times.</li>
|
|
<li><code>mksymb</code>: creates a symbol from its arguments,
|
|
upcasing strings as required.</li>
|
|
<li><code>mkkw</code>: creates a keyword from its arguments.</li>
|
|
<li><code>defclass!</code>: convenience macro for quickly defining
|
|
a class with slots and a docstring; it also builds a default
|
|
constructor based on a class's slots.</li>
|
|
</ul>
|
|
|
|
<h3>Quicklisp installation</h3>
|
|
|
|
<p>Clone into your Quicklisp project's <code>local-projects/</code>
|
|
subdirectory, and call <code>(ql:quickload :kutils)</code>.</p>
|
|
|
|
<p>This package does ake use of
|
|
the <a href="https://www.common-lisp.net/project/closer/closer-mop.html"><code>closer-mop</code></a>
|
|
package.</a>.
|
|
|
|
<h3>Git</h3>
|
|
|
|
<p>You can <a href="https://github.com/kisom/kutils">browse the
|
|
Github repository</a>.</p>
|
|
|
|
<div class="footer">
|
|
<a href="mailto:kyle (at) metacircular (dot) net">K. Isom</a>, 2015-04-06.
|
|
</div>
|
|
|
|
<div class="check">
|
|
<a href="http://validator.w3.org/check/referer">
|
|
Valid XHTML 1.0 Strict</a>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|