\documentclass[11pt,twocolumn]{article}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{alltt}
\usepackage{multicol}
\usepackage{color}
\usepackage{hyperref}

\hypersetup{colorlinks=true}

\textheight = 10.5 in
\linewidth = 8.0in
\oddsidemargin = 0.0 in
\evensidemargin = 0.0 in
\marginparwidth=0.0in
\marginparsep=0.0in
\topmargin = 0.0 in
\headheight = 0.0 in
\headsep = 0.0 in
\parskip = 1pt
\parindent = 0.0in

\setlength{\hoffset}{-24pt}
\setlength{\voffset}{-50pt}
\newcommand{\ttnrbf}[1]{\textnormal{\textbf{#1}}}
\newcommand{\ttitbf}[1]{\textnormal{\textbf{#1}}}
\newcommand{\ttit}[1]{\textit{#1}}
\newcommand{\sSecBox}[1]{\begin{minipage}{3in}\begin{alltt}{\small\textrm{\textbf{#1}}}}
%\newcommand{\sSecBox}[1]{\begin{minipage}{3in}\begin{alltt}{\small\textrm{\hrule\textbf{#1}}}}
%\newcommand{\eSecBox}{\end{alltt}\end{minipage}}
\newcommand{\eSecBox}{\end{alltt}\end{minipage}\rule{0pt}{1pt}\hrule}

\newcommand{\p}{\underline{p}}
\newcommand{\bnud}{\rule{2pt}{0pt}}

\newcommand{\aSymb}{\ttit{symb}}
\newcommand{\aChar}{\ttit{char}}
\newcommand{\aByteS}{\ttit{bytespec}}
\newcommand{\aHash}{\ttit{hash}}
\newcommand{\aBody}{\ttit{body}}
\newcommand{\aVal}{\ttit{value}}
\newcommand{\aVec}{\ttit{vector}}
\newcommand{\aArr}{\ttit{array}}
\newcommand{\aList}{\ttit{list}}
\newcommand{\aForm}{\ttit{form}}
\newcommand{\aInt}{\ttit{n}}
\newcommand{\aArg}{\ttit{arg}}
\newcommand{\aFunc}{\ttit{func}}
\newcommand{\aTest}{\ttit{test}}
\newcommand{\aString}{\ttit{string}}
\newcommand{\aName}{\ttit{name}}
\newcommand{\aPair}{\ttit{pair}}
\newcommand{\aSeq}{\ttit{seq}}
\newcommand{\aType}{\ttit{aType}}
\newcommand{\aBitVec}{\ttit{bit-vector}}
\newcommand{\aStream}{\ttit{stream}}
\newcommand{\aPath}{\ttit{path}}
\newcommand{\aBool}{\ttit{bool}}
\newcommand{\aPred}{\ttit{pred}}

\newcommand{\nByteS}[1]{\ttit{bytespec#1}}
\newcommand{\nPred}[1]{\ttit{predicate#1}}
\newcommand{\nPath}[1]{\ttit{path#1}}
\newcommand{\nBool}[1]{\ttit{bool#1}}
\newcommand{\nSeq}[1]{\ttit{seq#1}}
\newcommand{\nArg}[1]{\ttit{arg#1}}
\newcommand{\nSymb}[1]{\ttit{symb#1}}
\newcommand{\nBody}[1]{\ttit{body#1}}
\newcommand{\nVal}[1]{\ttit{value#1}}
\newcommand{\nList}[1]{\ttit{list#1}}
\newcommand{\nForm}[1]{\ttit{form#1}}
\newcommand{\nTest}[1]{\ttit{test#1}}
\newcommand{\nString}[1]{\ttit{string#1}}
\newcommand{\nInt}[1]{\ttit{int#1}}

%\newcommand{\blt}{\(\bullet\)}
\newcommand{\blt}{\makebox[2ex]{\(\bullet\)}}
\newcommand{\bsp}{\makebox[2ex]{}}

\newcommand{\srb}[2]{\parbox[t]{#1}{#2}\rule{5pt}{0pt}}

\begin{document}

\pagestyle{empty}

\fbox{{\parbox[b]{3.0in}{\huge \bf Common Lisp \\ \tiny \copyright 1997-2016 Mitch Richling \url{https://www.mitchr.me}  \\ Last Updated 2016-07-09}}}
\tiny

\sSecBox{Control: Code Blocks}
\blt (prog\{1|2|n\} \nForm{1} \ldots \nForm{n}) ;; Evaluate forms left to right.
\blt                                 ;; Returns \nForm{1}, \nForm{2}, or \nForm{n}
\blt (block \aSymb \nForm{1}\ldots) ;; A progn + name \& emergency exit (return-from)
\blt (return-from \aSymb [\aVal])  -- Break out of a block \aSymb \& return \aVal
\blt (return [\aVal])  ;; === (return-from nil [\aVal]) (think: 'do' blocks)
\blt (tagbody \ldots) ;; Atoms within a tagbody are LABELS that one may
\bsp                  ;; use 'go', as in (go 'foo), to jump to.  Many loop
\bsp                  ;; constructs implicitly use tagbody so go may be used.
\blt (error \aSymb)  ;; Print message \& Break to top level .
\blt (eval \aForm) ;; Evaluates \aForm as a lisp expression
\blt Short-cut, left-right, logical functions: and, or, not
\eSecBox

\sSecBox{Control: Conditionals}
\blt (if \aTest \nBody{-true} [\nBody{-false}])
\blt (when \aTest \nForm{-true})
\blt (unless \aTest \nForm{-false})
\blt (cond (\nTest{1} \nBody{1})      ;; The first \aBody with a true \aTest
\bsp       (\nTest{2} \nBody{2})...)  ;; clause is evaluated.
\eSecBox

\sSecBox{Control: Iteration (do)}
\blt (dotimes (\aSymb \aInt [\nForm{-ret}]) \aBody)  ;; Do \aBody \aInt times.
\bsp === (loop for \aSymb from 0 to (- \aInt 1) finally return \nForm{-ret} do \aBody)
\blt (dolist (\aSymb \aList [\nForm{-ret}]) \aBody) 
\bsp === (loop for \aSymb in \aList finally return \nForm{-ret} do \aBody)
\blt (do ((\ttit{symb1} \nVal{1} \nForm{-incr})\ldots) (\aTest [\nVal{-exit}]) \aBody)
\bsp   ;; Provides block and tagbody. do* to assigns/updates vars in order
\eSecBox

\sSecBox{Control: Iteration (loop)}
\blt (loop \aForm{1}\ldots) ;; If no KWs in \aForm{1}\ldots, then loop forever
\blt (loop [named \aSymb] \{\ttit{with|initially|finally|for}\}\ldots \aBody\ldots)
\blt KW Subs: \blt upfrom/downfrom ==> from
\bsp          \blt downto/upto ==> to        \blt  the ==> each
\bsp          \blt hash-key ==> hash-keys    \blt  hash-value ==> hash-values
\blt KW Control Clauses
  \blt for \aSymb upfrom \nVal{1} [\{upto | below\} \nVal{2}] [by \aVal{3}]
  \blt for \aSymb downfrom \nVal{1} [\{downto | above\} \nVal{2}] [by \aVal{3}]
  \blt for \aSymb in \aList [by \aFunc]  ;; Over list elements
  \blt for \aSymb on \aList [by \aFunc]  ;; Over list TAILS
  \blt for \aSymb = \nVal{1} [then \nVal{2}]\ldots
  \blt for \aSymb across \aVec or \aString
  \blt for \aSymb being the hash-keys of \aHash [using (hash-values \aVal)]
  \blt for \aSymb being the hash-values of \aHash [using (hash-keys \aVal)]
  \blt initially \aForm\ldots  ;; Evaluate as prologue
  \blt finally \aForm\ldots ;; Evaluate as part of epilogue
  \blt return \aForm ;; return value.  Skip epilogue
  \blt \{ if | when | unless \} \aForm{1} [else \aForm{2}] [end] ;; conditional
  \blt \{ collect[ing] | append[ing] | nconc[ing] | count[ing] | 
  \bsp   sum[ing] | maximize[ing] | minimize[ing] \} \aForm [into \aSymb]
  \blt repeat \aInt ;; Iteration stops after \aInt loops
  \blt while \aBool ;; Iteration stops when \aBool is nil
  \blt until \aBool ;; Iteration stops when \aBool is not nil
  \blt (loop-finish) ;; Causes a jump to the loop epilogue
  \blt (return-from [\aSymb [\aVal]]) ;; Return from loop
  \blt (return) ;; Return from loop
\blt Destructured binding examples
  \blt (loop for (a b) in '((x 1) (y 2)) collect (list a)) ====> (X Y)
  \blt (loop for (x . y) in '((1 . 2) (3 . 4)) collect y)  ====> (2 4)
\eSecBox


% (loop for i across "1235" do (print (char-to-string i)))
% (loop for i in '(1 2 3 4 5) do (print i))
% (loop for i from 1 to 5 by 1 do (print i))
% (loop for i from 5 downto 1 by 1 do (print i))
% (loop for i in '(1 2 3 4 5) do (print i))
% (loop for i on '(1 2 3 4 5) do (print i))
% (loop repeat 10 do (print "foo"))
% (loop initially (print "START") finally (print "END") for i from 1 to 3 do (print i))
% (loop (print "w"))
% (loop do (print "HELLO") repeat 10 do (print "FOO"))
% (loop for i from 1 to 5 by 1 do (print i))
% (loop for i from 0 to 5 when (oddp i) collect i)                                                                         ====> (1 3 5)
% (loop for i from 0 to 5 if (oddp i) collect i into odds else collect i into evens finally (return (list odds evens)))    ====> ((1 3 5) (0 2 4))
% (loop for (a b) in '((x 1) (y 2) (z 3)) collect (list b a) )                                                             ====> ((1 X) (2 Y) (3 Z))
% (loop for (x . y) in '((1 . 1) (2 . 4) (3 . 9)) collect y)                                                               ====> (1 4 9)
% (loop for i from 1 to 3 for x = (* i i) collect x)                                                                       ====> (1 4 9)



\sSecBox{Pair Construction \& Access}
\srb{70pt}{\blt Type Predicate: consp       }
\srb{70pt}{\blt (cons \nForm{1} \nForm{2})  };; Can use '(\nForm{1} . \nForm{2}) too
\srb{70pt}{\blt (car \aPair)                };; left part.  Settable!
\srb{70pt}{\blt (cdr \aPair)                };; right part.  Settable!
\srb{70pt}{\blt (rplaca \aPair \aForm)      };; Set (car \aPair) to \aForm. Destructive
\srb{70pt}{\blt (rplacd \aPair \aForm)      };; Set (cdr \aPair) to \aForm. Destructive
\eSecBox

\sSecBox{Lists}
\blt Type Predicate: listp, null (T if nil, else nil)
\blt (list \nForm{1} \nForm{2} \nForm{3} \ldots)
\blt (make-list \aInt \&K:Ie]) ;; Create list (initalize using KW)
\blt nil <==> ()  ;; Empty list.
\blt (append \aList \ldots)
\blt (nconc \nList{1} \nList{2}) ;; Destructively add \nList{2} to \nList{1}
\blt (nreconc \nList{1} \nList{2}) ;; Same as (nconc (nreverse x) y)
\blt (cons \aForm \aList) ;; Prepend \aList with \aForm
\blt Named elements: first, second, third, fourth, fifth, \ldots, tenth
\blt (car \aList)    ;; first element 
\blt (cdr \aList)    ;; all but first element
\blt Compositions of car \& cdr have names, (cadr \aList)<=>(car (cad \aList)).
\blt  Forms exist up to four compositions(Perl regex:  m/^c[ad]\{2,4\}r$/).
\blt (rest \aList)   ;; all but first element
\blt (last \aList [\aInt]) ;; Last cons (or \aInt to last)
\blt (nth 5 \aList)  ;; get nth element (zero indexed)
\blt (nthcdr \aInt \aList) ;; get nth cdr (nth element on) (zero indexed)
\blt (mapcar \aFunc \nList{1}\ldots)   ;; Apply \aFunc the lists in parallel
\blt (mapc \aFunc \nList{1})     ;; Like mapcar, but returns \aList
\blt (copy-list \aList)     ;; Create a copy of \aList
\blt (copy-tree \aList)     ;; Recursively copy \aList and its sublists
\blt (subst \nVal{1} \nVal{2} \aList \&K:TTnK) ;; Recessive version of substitute 
\blt (sublis \aList \aList \&K:TTnK) ;; Recurrsively replace all keys with values
\blt (tree-equal \nList{1} \nList{2}  \&K:TTn)
\blt (list-length \aList) ;; Length of list.  Works with circular lists.
\blt (butlast \aList [\aInt]) ;; List except last \aInt elements.
\blt (member \aVal \aList \&K:TTnK)  ;; Returns from first match on to end
\blt (adjoin \aForm \aList \&K:TTnK) ;;  Add to \aList unless \aForm is in \aList
\blt (subsetp \nList{1} \nList{2} \&K:TTnK) ;; T if every ele of \nList{1} in \nList{2}
\blt Set Operators: union, intersection, set-difference, set-exclusive-or
\blt Alternate, DESTRUCTIVE, forms:
\bsp    \blt nsubst   \blt nbutlast  \blt nintersection    \blt nset-exclusive-or
\bsp    \blt nsublis  \blt nunion    \blt nset-difference
\blt Alternate -if, -if-not forms: 
\bsp    \blt (nsubst-if \aPred \aList \&K:K)  \blt (nsubst-if-not \aPred \aList \&K:K)
\bsp    \blt (subst-if \aPred \aList \&K:K)   \blt (subst-if-not \aPred \aList \&K:K)
\bsp    \blt (member-if \aPred \aList \&K:K)  \blt (member-if-not \aPred \aList \&K:K) 
\eSecBox

\sSecBox{Types}
\blt atomp, symbolp
\blt (typep \aForm \aSymb) ;; t if \aForm os of type \aSymb
\blt (type-of \aForm) ;; Return the type of \aForm
\eSecBox

\sSecBox{Numbers}
\blt Type Tree (\p means a type predicate exists)
\bsp   number\p -+- real\p -+- float\p -----------------------------------+- short-float 
\bsp            |         +- rational\p -+- ratio                       +- single-float
\bsp            |                       +- integer\p -+- bignum         +- double-float
\bsp            +- complex\p                          +- fixnum -- bit  +- long-float  
\blt Number Classes: evenp, oddp, zerop, plusp, minusp
\blt Conversion: float, truncate, floor, ceiling, 
\bsp             rationalize, rational, (complex \nVal{1} [\nVal{2}])
\blt Parts: numerator, denominator (always positive), realpart, imagpart
\blt Comparison \& Arithmetic : =, >, <, <=, >=, *, /, +, -
\blt Special Syntax: \blt Rational: \nVal{1}/\nVal{2}                        
\bsp                 \blt Float: m.Xn (m, n integers).
\bsp                 \bsp   \blt X=s for short-float  \blt X=f for single-float
\bsp                 \bsp   \blt X=d for double-float \blt X=l for long-float
\blt (random \aVal) ;; Random number less than \aVal and of the same numeric type
\eSecBox

\sSecBox{\# Notation}
\blt #0  octal rat   #O777/2                \blt #' Function        #'+                
\blt #C  complex     #C(1 2)                \blt #( simple vec      #(1 2 3)           
\blt #B  binary rat  #B101/11 <=> 5/3       \blt #* bit vec         #*101001            
\blt #nA array       #2A((1 2) (3 4))       \blt #\verb+\+ char            #\verb+\+a  
\blt #S  structure   #S(pnt x 10 y 23)      \blt #X hex rational    #Xf00              
\blt #n( Simple Vec  #4n(1 2 3 4)           \blt #n* simple bit-vec #6*101001            
\blt #nR Base n Rat  #3R1021                \blt #|\ldots#| Comment
\eSecBox

\sSecBox{Traditional Mathematical Functions}
\blt sqrt  \blt sin  \blt gcd  \blt asin  \blt sinh  \blt asinh  \blt round     \blt conjugate   
\blt mod   \blt tan  \blt lcm  \blt atan  \blt tanh  \blt atanh  \blt realpart  \blt ceiling                     
\blt min   \blt cos  \blt abs  \blt acos  \blt cosh  \blt acosh  \blt imagpart  
\blt max   \blt exp  \blt log  \blt isqrt \blt expt  \blt floor  \blt signum    
\eSecBox

\sSecBox{Equality}
\blt equal  objects logically the same            \blt eq   same address            
\blt equalp Liberal equal (ignores case...)       \blt =    works with numbers      
\blt eql    equal for same numeric type, else eq
\eSecBox

\sSecBox{Bit Vectors (0's \& 1's)}
\blt Make a bit-vector: (make-array \aInt :element-type 'bit :initial-element 0)
\blt Type Predicate: bit-vector-p, simple-bit-vector-p
\blt (bit \aBitVec \aInt) ;; like aref, just for bit-vectors
\blt (sbit \aBitVec \aInt) ;; like svref, just for bit-vectors
\blt Bit operations: bit-eqv, bit-xor, bit-nand, bit-and, bit-not, bit-nor
\eSecBox

\sSecBox{Path \& File Names}
\blt Type Predicate: pathnamep
\blt (make-pathname \ldots)  ;; Create a pathname object.  KW parms:
\bsp  \blt :directory  \blt :name  \blt :host  \blt :device  \blt :type  \blt :version
\blt Path to string: file-namestring, directory-namestring, namestring
\blt Component access: pathname-directory, pathname-name \aPath
\eSecBox

\sSecBox{File System}
\srb{111pt}{\blt (delete-file \aPath)              };; Delete the file given by \aPath
\srb{111pt}{\blt (directory \aPath)                };; list of files in path
\srb{111pt}{\blt (ensure-directories-exist \aPath) };; Create every directory on path
\srb{111pt}{\blt (file-write-date \aPath)          };; last modify time for file
\srb{111pt}{\blt (probe-file \aPath)               };; nil if file dose not exist
\srb{111pt}{\blt (rename-file \nPath{1} \nPath{2}) };; rename \nPath{1} to \nPath{2}
\srb{111pt}{\blt (truename \aPath)                 };; real name of file at \aPath
\eSecBox

\sSecBox{Streams}
\blt Type/State Predicates: streamp, input-stream-p, 
\bsp   interactive-stream-p, open-stream-p,output-stream-p
\blt (open \aPath) ;; Returns a Stream.  Useful KW args:
\bsp   \blt :direction [:input | :output | :io]
\bsp   \blt :if-exists [:error | :overwrite | :append | :supersede]
\bsp   \blt :element-type ['base-character | 'character | 'unsigned-byte ]
\blt (file-length \aStream)  
\blt (file-position \aStream [\aInt]) ;; queries or sets file pointer
\blt (finish-output [\aStream])
\blt (clear-input  [\aStream]) ;; throw away any waiting input
\blt (close \aStream)
\eSecBox

\sSecBox{I/O}
\blt (with-open-file (\aSymb \aStream [\ttit{open-args}]) \aBody)
\blt (with-open-file (\aSymb \aString) \aBody) ;; Not portable, but handy
\blt (with-open-stream (\aSymb \aStream) \aBody) 
\blt (read [\aStream] [\nBool{-err-on-EOF}] [\nVal{-ret-on-EOF}])  ;; read LISP
\blt (with-output-to-string (\aSymb [\aString]) \aBody) 
\bsp    ;; printed string is returned if \aString not given
\blt (read-line [\aStream] [\nBool{-err-on-EOF}] [\nVal{-ret-on-EOF}])
\blt (read-from-string \aString [\nBool{-err-on-EOF}] [\nVal{-ret-on-EOF}])
\blt (read-char [\aStream] [\nBool{-err-on-EOF}] [\nVal{-ret-on-EOF}])
\blt (read-byte [\aStream] [\nBool{-err-on-EOF}] [\nVal{-ret-on-EOF}]) ;; return int
\blt (write-byte \aInt [\aStream])
\blt (peek-char [\aBool] [\aStream] [\nBool{-err-on-EOF}] [\nVal{-ret-on-EOF}])
\blt (fresh-line [\aStream])  ;; write newline if not at start of line
\blt (terpri)       ;; Move to newline
\blt (print \aForm [\aStream]) ;; LISP like
\blt (prin1 \aForm [\aStream]) ;; No NL
\blt (princ \aForm [\aStream]) ;; Human like
\blt Print to strings: princ-to-string, prin-to-string
\blt (dribble [\aString]) ;; print session to file.  Stop if no argument.
\blt (load \aString) ;; load named file and evaluate lisp
\eSecBox

\sSecBox{Format}
\blt (format \nVal{-dst} \nString{-fmt} \nForm{1}\ldots) 
\bsp  ;; \nVal{-dst} may be T (for STDOUT), NIL (for a string), or a \aStream  
\bsp    \blt     ~r,wR Base r int     \blt ~wA Like princ (@ right justifies)
\bsp    \blt       ~wD Decimal int    \blt ~wS Like prin1 (@ right justifies)
\bsp    \blt       ~wB Binary int     \blt ~wW Like write (@ right justifies)
\bsp    \blt       ~wO Octal int      \blt ~wC Character             
\bsp    \blt       ~wX Hex int        \blt ~n% n newlines            
\bsp    \blt   ~w,d,sF Float          \blt ~n& n smart newlines
\bsp    \blt ~w,d,e,sE Exp Float      \blt ~nT Move to Col n         
\bsp    \blt ~w,d,e,sG do F or E      
\bsp  d=digits before dec, s=digits after dec, e=exp digits, w=width
\bsp  R,D,B,O,X Mods: '@' prints + signs & ':' prints commas
\eSecBox

\sSecBox{Arrays}
\blt Type Predicate: arrayp
\blt (make-array '(\ttit{dim1}\ldots) \&key :Ie :adjustable :initial-contents)
\blt (adjust-array \aArr \ttit{new-dim} \$key \ldots)
\blt (aref \aArr \nInt{1}\ldots) ;; Array element access. Zero-indexed.  Settable.
\blt (array-dimension \aArr \aInt) ;; Length of \aInt-th dim.  Zero-indexed
\blt (array-dimensions \aArr) ;; List of ints representing dimensions.
\blt (array-element-type \aArr)
\blt (array-rank \aArr) ;; Returns the number of dimensions
\blt (array-total-size \aArr) ;; Returns number of locations in \aArr.
\eSecBox

\sSecBox{Vectors}
\textsc{NOTE: Vectors are 1D arrays -- so all array functions work.}
\blt Type Predicates: vectorp, simple-vector-p
\blt (vector \nForm{1}\ldots) ;; Create new vector from \nForm{1}\ldots
\blt (svref \aVec \aInt) ;; Just like aref, but faster for SIMPLE VECTORS
\blt (setf (aref \aVec \aInt) \aForm) ;; Can setf an aref like this
\eSecBox

\sSecBox{Characters}
\blt Type Predicate: characterp
\blt (character \aInt) or (character \aChar)
\blt (char-code \aChar) ;; Return numeric code for character
\blt (char-name \aChar) ;; Return string for \aChar
\blt (code-char \aInt)  ;; Return char for code
\blt Character Transformation: char-upcase, char-downcase
\blt Binary Predicates: char<, char>, char<=, char=, 
\bsp  char>=, char/=, char-not-greaterp, char-equal, 
\bsp  char-lessp, char-not-lessp, char-greaterp, char-not-equal
\blt Class Predicates: digit-char-p, alpha-char-p, graphic-char-p, 
\bsp  lower-case-b, upper-case-p, alphanumericp, standard-char-p
\eSecBox

\sSecBox{Strings}
\textsc{NOTE: Strings are vectors of characters.}
\blt "I am a string"  ;; Syntax for a string literal
\blt Type Predicate: stringp, simple-string-p
\blt (string \aForm) ;; Convert symbols/characters/strings to strings
\blt (char \aString \aInt) ;; same as (aref \aString \aInt)
\blt (schar \aString \aInt) ;; same as svref (simple strings)
\blt (substring \aString \nVal{1} \nVal{2}) ;; Same as subseq
\blt (make-string \ttit{size} \&key :Ie :element-type) ;; Same as make-array
\blt (string-width \aString) ;; same as length
\blt (string-concat \nString{1} \nString{2}\ldots) ;; specialized as concatenate
\blt String Transformations: string-capitalize, string-downcase,
\bsp  string-left-trim, string-right-trim, string-trim, string-upcase
\bsp  \textsc{Prefix ``N'' to transformations to get a destructive version}
\bsp  \textsc{Case transformations take keyword parmaters:} \&K:SE
\blt Binary Predicates: string-lessp, string/=, string-not-equal,
\bsp  string<, string-not-greaterp, string<=, string-not-lessp, string=, 
\bsp  string>, string-equal, string>=, string-greaterp
\bsp  \textsc{All binary predicates take keyword parmaters:} \&K:S1E1S2E2
\eSecBox

\sSecBox{Structures}
\blt (defstruct \aSymb \nSymb{1}\ldots) 
\bsp   Define a structure named \aSymb with members \nSymb{N}
\bsp   This will create several functions/macros including:
\bsp   \blt make-\aSymb                \blt \aSymb-p
\bsp   \blt copy-\aSymb                \blt \aSymb-\nSymb{N} for all N
\bsp   \blt Instance: #S(\aSymb \nVal{1}\ldots)
\eSecBox

\sSecBox{Associative Lists}
\srb{110pt}{\blt (assoc \nForm{-key} \aList \&K:TTnK)     };; find pair with given key
\srb{110pt}{\blt (rassoc \nForm{-value} \aList \&K:TTnK)  };; find pair with given value
\srb{110pt}{\blt (acons \nForm{-key} \nVal{-form} \aList) };; Add pair to list
\srb{110pt}{\blt (copy-alist \aList)                      };; Make a copy of list.
\srb{110pt}{\blt (pairlis \nList{-keys} \nList{-vals})    };; Build a-list from parts.
\blt Alternate -if, -if-not forms:
\bsp   \blt (assoc-if \aPred \aList \&K:K)  \blt (assoc-if-not \aPred \aList \&K:K)
\bsp   \blt (rassoc-if \aPred \aList \&K:K) \blt (rassoc-if-not \aPred \aList \&K:K)
\blt Examples
\bsp \blt (assoc "a" '(("a" . 1) ("b" . 2)) :test #'string=) ===> ("a" . 1)
\bsp \blt (assoc :a '((:a . 1) (:b . 2)))                    ===> (:A . 1)
\eSecBox

\sSecBox{Hash Tables}
\blt Type Predicate: hash-table-p
\blt (clrhash \aHash)
\blt (hash-table-count \aHash) ;; Number of entries
\blt (hash-table-size \aHash)  ;; Size of hash table
\blt (maphash \aFunc \aHash)  ;; Apply \aFunc to each entry in \aHash
\blt (make-hash-table [:size \aInt] [:text \aFunc])  ;; Create has table
\blt (gethash \aSymb \aHash) ;; Returns object or nil. Settable.
\blt (rmhash \aSymb \aHash) ;; Remove \aSymb from \aHash
\blt (with-hash-table-iterator (\aSymb \aHash) \aBody\ldots)
\eSecBox

\sSecBox{Integer Bit \& Byte Manipulation}
\blt (byte \nVal{-size} \nVal{-position})  ;; Create a \aByteS
\blt Byte Spec component access: byte-size, byte-position
\blt (ldb \aByteS \aInt) ;; Extract part of integer and shift
\blt (ldb-test \aByteS \aInt) ;; Are any of the bits 1
\blt (mask-field \aByteS \aInt) ;; Extract part and leave it in place
\blt (dpb \nByteS{1} \nByteS{2} \aInt)
\blt (deposit-field \nByteS{1} \nByteS{2} \aInt) ;; \nByteS{1} to \nByteS{2}
\blt (logcount \nInt{1}) ;; Returns the number of '1' bits in \nInt{1}
\blt Logical, bitwise, operations on integers 
\bsp   \blt logxor    \blt lognand   \blt lognor  \blt logior (inclusive or)    
\bsp   \blt logand    \blt logandc2  \blt logorc2 \blt logeqv (exclusive nor)   
\bsp   \blt logandc1  \blt logorc1   \blt lognot  
\bsp   \blt logtest ;; t if (and \nInt{1} \nInt{2}) not zero
\bsp   \blt (logbitp \nInt{1} \nInt{2})  t if bit \nInt{1} of \nInt{2} is 1
\bsp   \blt (ash \nInt{1} \nInt{2})  ;; Shift \nInt{1} left \nInt{2} bits (\nInt{2}<0 is OK)
\bsp   \blt (boole \ttit{op} \nInt{1} \nInt{2} ;; Any of the 16 boolean, binary ops
\bsp       Op must be one of (all names prefixed with "boole"):
\bsp         a  0 0 1 1    a   0 0 1 1    a  0 0 1 1    a    0 0 1 1 
\bsp         b  0 1 0 1    b   0 1 0 1    b  0 1 0 1    b    0 1 0 1
\bsp       -clr 0 0 0 0  -xor  0 1 1 0  -c1  1 1 0 0  -andc1 0 1 0 0
\bsp       -set 1 1 1 1  -eqv  1 0 0 1  -c2  1 0 1 0  -andc2 0 0 1 0
\bsp       -1   0 0 1 1  -nand 1 1 1 0  -and 0 0 0 1  -orc1  1 1 0 1
\bsp       -2   0 1 0 1  -nor  1 0 0 0  -ior 0 1 1 1  -orc2  1 0 1 1
\eSecBox

\sSecBox{Variables}
\blt (let ((\nSymb{1} \nVal{1})\ldots) \aBody\ldots)              ;; Declare local variables
\blt (let* ((\nSymb{1} \nVal{1})\ldots) \aBody\ldots)             ;; Declare local variables (in order)
\blt (defparameter \aSymb \aVal [\aString])             ;; Declare global variable 
\blt (defvar \aSymb [\aVal [\aString]])                 ;; Declare global Variable
\blt (defconstant  \aSymb \aVal [\aString])             ;; Declare global constant
\blt (defun \aName \nList{-lambda} [\nString{-doc}] \aBody\ldots)  ;; Declare global function
\bsp    ;; Add (interactive) before \aBody\ldots for EMACS interactive function
\blt (defun (setf \aName) \nList{-lambda} \aBody\ldots)        ;; Define setf behavior for \aName
\bsp    ;; \nArg{-val} is the new value given to setf.
\blt (defsetf
\blt (setf \aSymb \aVal)   ;; Set variables (speical, global, local, ...)
\blt (incf \aSymb [\nSymb{1}]) ;; Same as (setf \aSymb (+ \aSymb \nSymb{1}))
\blt (decf \aSymb [\nSymb{1}]) ;; Same as (setf \aSymb (- \aSymb \nSymb{1}))
\blt (push \aVal \aSymb)    ;; Same as (setf \aSymb (cons \aVal \aSymb))
\blt (pushnew \aVal \aSymb \&K:TTnK) ;; push only if \aVal no in \aSymb already
\blt (pop \aSymb)           ;; Returns (car \aSymb) & sets \aSymb to (cdr \aSymb)
\blt (boundp \aSymb)        ;; t if \aSymb is bound to a non-function
\blt (fboundp \aSymb)       ;; t if \aSymb is bound to a function
\eSecBox

\sSecBox{Functions}
\blt Type Predicates: compiled-function-p, functionp
\blt (function \aSymb)           ;; Returns the function bound to \aSymb
\blt (lambda (\nList{-lambda}) \aBody\ldots) ;; Define function
\bsp   The \nList{-lambda} is of the form:
\bsp     \aSymb \ldots                            ;; Arg List
\bsp     [\&optional \nSymb{1} [\nVal{1}] \ldots] ;; Optional args
\bsp     [&rest \aSymb]                           ;; Rest of args
\bsp     [&key \nSymb{1} [\nVal{1}] \ldots]       ;; Key-value args
\blt (funcall \aName \nArg{1}\ldots) ;; like apply, but last arg need not be list
\blt (apply \aName \nArg{1} ...\aList) ;; Apply function with arguments in 
\bsp                            ;; list: append(\nArg{1}\ldots \aList).  Much like funcall
\bsp                            ;; See maplist to apply a function to each element of a list
\bsp                            ;; See reduce to apply function recursively to list
\blt (values [nArg{1}\ldots]) ;; Return zero or more values
\blt (values-list \aList) ;; Like values, but returns list elements
\blt (multiple-value-list \aBody) ;; Evaluates \aBody and returns a LIST of returns from \aBody
\blt (multiple-value-bind (\nSymb{1}\ldots) \aBody \nBody{1}\ldots) ;; Eval \aBody, bind returns, eval rest
\blt (multiple-value-setq (\nSymb{1}) \aBody) ;; Eval \aBody, and set variables.
\blt (compile \aSymb) ;; Compile a function
\eSecBox

\sSecBox{Sequences}
\textsc{NOTE: Sequences include lists \& vectors (and thus strings too)}
\blt (make-sequence \aType \ttit{size} &K:Ie)
\blt (concatenate \aType \nSeq{1}\ldots) ;; Concatenates given sequences
\blt (count \aForm \aSeq \&K:FeTTnSEK) ;; Count elements in \aSeq matching \aForm
\blt (copy-seq \aSeq)
\blt (elt \aSeq \aInt)  ;; Return the \aInt element of \aSeq
\blt (fill \aSeq \aVal \&K:SE) ;; Fill \aSeq with \aVal
\blt (find \aVal \aSeq \&K:FeTTnSEK)      ;; Returns \aVal if found
\blt (length \aSeq)
\blt (map \aType \aFunc \aSeq) ;; Like mapc but for sequences
\blt (map-into \aSeq \aFunc \nSeq{1}) ;; destructive map.  Result into \aSeq
\blt (mismatch \nSeq{1} \nSeq{2} \&K:KFeTTnKS1S2E1E2) ;; Return position of first mismatch
\blt (position \aVal \aSeq \&K:FeTTnSEK) ;; Returns zero based index of \aVal in \aSeq, else nil.
\blt (reduce \aFunc \aSeq \&K:FeSEIv) ;; recursively apply binary function \aFunc
                      ;; to elements of \aSeq returning one atomic value.
\blt (remove \aVal \aSeq \&K:FeTTnSECK) ;; Remove all occurrences of \aVal from \aSeq
\blt (reverse \aSeq)
\blt (merge \aType \nSeq{1} \nSeq{2} \aPred \&K:K) ;; Destructively merge with sorting predicate \aPred
\blt (sort \aSeq \aPred \&K:K) ;; WARNING: DESTRUCTIVE!! (\aPred - binary comparison)
\blt (subseq \aSeq \nVal{-start} [\nVal{-end}])
\blt (substitute \nVal{1} \nVal{2} \aSeq \&K:FeTTnSECK) ;; Replace \nVal{1} for \nVal{2} in \aSeq
\blt (every \aFunc \nSeq{1}\ldots)    ;; Apply \aFunc like mapcar, return T if \aFunc was never nil
\blt (notany \aFunc \nSeq{1}\ldots)   ;; Simlar to every, but diffrent :)
\blt (notevery \aFunc \nSeq{1}\ldots) ;; Simlar to every, but diffrent :)
\blt (some \aFunc \nSeq{1}\ldots)     ;; Simlar to every, but diffrent :)
\blt (search \nSeq{1} \nSeq{2} \&K:FeTTnKS1S2E1E2) ;; Find \nSeq{1} in \nSeq{2}.  Return index.
\blt (remove-duplicates \aSeq \&K:FeTTnSEK) ;; Remove duplicate objects from \aSeq
\blt Alternate, -if and -if-not forms:
\bsp   \blt (count-if \aPred \aSeq \&K:FeSEK)      \blt (count-if-not \aPred \aSeq \&K:FeSEK)    
\bsp   \blt (find-if \aPred \aSeq \&K:FeSEK)       \blt (find-if-not \aPred \aSeq \&K:FeSEK)     
\bsp   \blt (position-if \aPred \aSeq \&K:FeSEK)   \blt (position-if-not \aPred \aSeq \&K:FeSEK) 
\bsp   \blt (remove-if \aPred \aSeq \&K:FeSECK)    \blt (remove-if-not \aPred \aSeq \&K:FeSECK)   
\bsp   \blt (delete-if \aPred \aSeq \&K:FeSECK)    \blt (delete-if-not \aPred \aSeq \&K:FeSECK)
\bsp   \blt (substitute-if \nVal{1} \aPred \aSeq)  \blt (substitute-if-not \nVal{1} \aPred \aSeq \&K:FeSECK)
\blt Alternate, DESTRUCTIVE, forms:
    \blt nreverse     \blt nsubstitute-if      \blt delete-duplicates (see: remove-duplicates)
    \blt nsubstitute  \blt nsubstitute-if-not  \blt delete (see: remove)
\eSecBox

\sSecBox{Keword Argument Key}
\blt :key   :K  Function used before :test   \blt :from-end :Fe Work in reverse        
\blt :test  :T  Test to use for comparison   \blt :start    :S  Where to start working 
\blt :end   :E  Where to stop working        \blt :test-not :Tn Test to use for comparison      
\blt :end1  :E1 Where to stop working Arg1   \blt :start1   :S1 Where to start working Arg1     
\blt :end2  :E2 Where to stop working Arg2   \blt :start2   :S2 Where to start working Arg2     
\blt :count :C  How many times/elements
\blt :initial-element :Ie  Initializeing element for various make-* functions
\blt :initial-value   :Iv  Initializeing value for a accumulator
\textsc{In the listings, } \&K: \textsc{indicates that the \&key argument list is}
\textsc{completely abreviated.  For example:}
       (foo \&K:TTnK) <=> (foo \&key :test :test-not :key)
\textsc{A key argument that is in upper case and cosists of justoposed abrevations}
\textsc{from above, should be assumed to be abreviations. For example:}
       (foo \&key :bar :TK) <=> (foo \&key :bar :test :key)
\eSecBox


\end{document}
