\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{heow} \pdfinfo{ /Title (core-common-lisp-top-100-ulisp-subset.pdf) /Creator (Cheatography) /Author (heow) /Subject (Core Common Lisp Top 100 - uLisp Subset Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{468CC8} \definecolor{LightBackground}{HTML}{F3F7FB} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Core Common Lisp Top 100 - uLisp Subset Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{heow} via \textcolor{DarkBackground}{\uline{cheatography.com/186454/cs/38972/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}heow \\ \uline{cheatography.com/heow} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 6th June, 2023.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{tabularx}{17.67cm}{x{2.5905 cm} x{14.6795 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Symbols}} \tn % Row 0 \SetRowColor{LightBackground} nil & A symbol equivalent to the empty list (). \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} t & A symbol representing true. \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \seqsplit{nothing} & A symbol with no value. It is useful if you want to suppress printing the result of evaluating a function. It is equivalent to (values) in Common Lisp. \tn % Row Count 8 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{2.5905 cm} x{14.6795 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{List Functions}} \tn % Row 0 \SetRowColor{LightBackground} cons & {\bf{(cons {\emph{item}} {\emph{item}})}} If the second argument is a list, cons returns a new list with item added to the front of the list. \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} car & {\bf{(car {\emph{list}})}} or {\bf{(first {\emph{list}})}} Returns the first item in a list. \tn % Row Count 7 (+ 3) % Row 2 \SetRowColor{LightBackground} cdr & {\bf{(cdr {\emph{list}})}} or {\bf{(rest {\emph{list}})}} Returns a list with the first item removed. \tn % Row Count 10 (+ 3) % Row 3 \SetRowColor{white} list & {\bf{(list {\emph{item}} {\emph{item}} ...)}} Returns a list of the values of its arguments. \tn % Row Count 13 (+ 3) % Row 4 \SetRowColor{LightBackground} \seqsplit{append} & {\bf{(append {\emph{list}} {\emph{list}} ...)}} Joins its arguments, which should be lists, into a single list. \tn % Row Count 16 (+ 3) % Row 5 \SetRowColor{white} \seqsplit{length} & {\bf{(length {\emph{item}})}} Returns the number of items in a list, the length of a string, or the length of a one-dimensional array. \tn % Row Count 20 (+ 4) % Row 6 \SetRowColor{LightBackground} \seqsplit{reverse} & {\bf{(reverse {\emph{list}})}} Returns a list with the elements of list in reverse order. \tn % Row Count 23 (+ 3) % Row 7 \SetRowColor{white} nth & {\bf{(nth {\emph{number}} {\emph{list}})}} Returns the nth item in a list, counting from zero. \tn % Row Count 26 (+ 3) % Row 8 \SetRowColor{LightBackground} sort & {\bf{(sort {\emph{list}} {\emph{test}})}} Sorts the list according to the test function, and returns the sorted list. Note that for efficiency the sort is destructive, meaning that the value of list may be changed by the operation. \tn % Row Count 33 (+ 7) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{p{2.2451 cm} x{15.0249 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Defining Variables and Functions}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{lambda} & {\bf{(lambda (p1 p2 ...) {\emph{form}} ...)}} Creates an unnamed function with parameters. Named functions are usually defined with {\bf{defun}}. The usual use of lambda is to create a function for {\bf{mapcar}}. Example: {\bf{((lambda (x y) (+ x y)) 4 3)}} \tn % Row Count 8 (+ 8) % Row 1 \SetRowColor{white} defun & {\bf{(defun name (p1 p2 ...) {[}{\emph{docstring}}{]} {\emph{form}} ...)}} Allows you to define a function. Example: {\bf{(defun sq (x) (* x x))}} \tn % Row Count 12 (+ 4) % Row 2 \SetRowColor{LightBackground} \seqsplit{defvar} & {\bf{(defvar {\emph{variable}} {\emph{form}})}} Defines a global variable. \tn % Row Count 14 (+ 2) % Row 3 \SetRowColor{white} setq & {\bf{ (setq {\emph{sym1}} {\emph{val1}} {[}{\emph{sym2}} {\emph{val2}}{]}...)}} Assigns the value to the symbol, optionally make several assignments. Example: {\bf{(setq a (+ 2 3) b (+ 4 5))}} \tn % Row Count 19 (+ 5) % Row 4 \SetRowColor{LightBackground} let & {\bf{(let (({\emph{var}} {\emph{value}}) … ) {\emph{forms}})}} Declares local variables then evaluates forms with those local variables. Example: {\bf{(let ((a 1) (b 2)) (* a a b))}} \tn % Row Count 24 (+ 5) % Row 5 \SetRowColor{white} let* & Like let, but you can refer to local variables that have already been defined. Example: {\bf{(let* ((a 7) (b a)) (* a b))}} \tn % Row Count 28 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{5.0083 cm} x{12.2617 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Strings}} \tn % Row 0 \SetRowColor{LightBackground} string\textless{}, string\textgreater{} & {\bf{(string\textless{} {\emph{string}} {\emph{string}})}} Returns t if the first string is alphabetically less than (or greater than) the second string, and nil otherwise. \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} string= & {\bf{(string= {\emph{string}} {\emph{string}})}} Tests whether two strings are the same. \tn % Row Count 9 (+ 3) % Row 2 \SetRowColor{LightBackground} stringp & {\bf{(stringp {\emph{item}})}} Returns t if the argument is a string and nil otherwise. \tn % Row Count 12 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{concatenate} & {\bf{(concatenate 'string {\emph{string}} ...)}} Joins together the strings given in the second and subsequent arguments and returns a single string. Example: {\bf{(concatenate 'string "One" "Two" "Three") ⮕ "OneTwoThree"}} \tn % Row Count 20 (+ 8) % Row 4 \SetRowColor{LightBackground} \seqsplit{princ-to-string} & (princ-to-string item) Prints its argument to a string, and returns the string. Example: {\bf{(princ-to-string (* 2 3 4)) ⮕ "24"}} \tn % Row Count 25 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{2.9359 cm} x{14.3341 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Math Functions}} \tn % Row 0 \SetRowColor{LightBackground} + - * & {\bf{(+ {\emph{number}} {\emph{number}} ...)}} Adds, subtracts or multiplies its arguments together. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \textbackslash{} & {\bf{(/ {\emph{number}} ...)}} Divides arguments. If there is one argument, inverts the argument. If there are two or more arguments, divides the first argument by the second and subsequent arguments. Example: {\bf{(/ 60 2 3) ⇨ 10}} \tn % Row Count 10 (+ 7) % Row 2 \SetRowColor{LightBackground} mod & {\bf{(mod {\emph{number}} {\emph{number}})}} Returns its first argument modulo the second argument. \tn % Row Count 13 (+ 3) % Row 3 \SetRowColor{white} abs & {\bf{(abs {\emph{number}})}} Returns the absolute, positive value of its argument. \tn % Row Count 16 (+ 3) % Row 4 \SetRowColor{LightBackground} \seqsplit{random} & {\bf{(random {\emph{number}})}} Returns a random number between 0 and one less than its argument. \tn % Row Count 19 (+ 3) % Row 5 \SetRowColor{white} min, max & {\bf{(min {\emph{number}} ...)}} Returns the minimum or maximum of one or more arguments. \tn % Row Count 22 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{4.6629 cm} x{12.6071 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Numeric Comparisons}} \tn % Row 0 \SetRowColor{LightBackground} =, \textless{}, \textless{}=, \textgreater{}, \textgreater{}= & {\bf{(= {\emph{number}} {\emph{number}} ...)}} Equal, less than (or equal) etc. Returns {\bf{t}} if the comparison succeeds. Example: {\bf{(\textgreater{} 4 2 1) ⇨ t}} \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} /= & {\bf{(/= {\emph{number}} {\emph{number}} ...)}} Not equal. Returns t if none of the arguments are equal, and nil if two or more arguments are equal. In the C Language, it is "!=" \tn % Row Count 11 (+ 6) % Row 2 \SetRowColor{LightBackground} plusp, minusp & {\bf{(plusp number)}} Returns t if the argument is greater than (with minusp, less than) zero, or nil otherwise. Note that (plusp 0) is nil. \tn % Row Count 16 (+ 5) % Row 3 \SetRowColor{white} zerop & {\bf{(zerop number)}} Returns t if the argument is zero, or nil otherwise. \tn % Row Count 19 (+ 3) % Row 4 \SetRowColor{LightBackground} evenp, oddp & {\bf{(evenp number)}} Returns t if the number is even (or odd) otherwise nil. \tn % Row Count 22 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{3.9721 cm} x{13.2979 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Logic and Conditionals}} \tn % Row 0 \SetRowColor{LightBackground} if & {\bf{(if {\emph{test}} {\emph{then}} {[}{\emph{else}}{]})}} Evaluates test. If it's non-nil the form then is evaluated and returned; otherwise the form else is evaluated and returned. The else form is optional. Example: {\bf{ (if (= foo 42) "woohoo" "just a number"))}} \tn % Row Count 8 (+ 8) % Row 1 \SetRowColor{white} cond & {\bf{(cond (({\emph{test}} {\emph{form}}...) … ))}} Cond provides a more flexible structure, each argument is a list consisting of a test optionally followed by one or more forms. If the test evaluates to non-nil the forms are evaluated and the last value is returned. If the test evaluates to nil, none of those forms are evaluated. Example: {\bf{(cond ((\textless{} a 64) "low") ((\textless{} a 192) "high") (t "error"))}} Also see \{\{link="http://www.ulisp.com/show?3L\#case"\}\}case\{\{/link\}\} \tn % Row Count 24 (+ 16) % Row 2 \SetRowColor{LightBackground} when, unless & {\bf{(when {\emph{test}} {\emph{form}} ...)}} Evaluates the test. If it's non-nil (nil for {\bf{unless}}) the forms are evaluated and the last value is returned. Example: {\bf{(when (digitalread 3) (digitalwrite 4 t))}} \tn % Row Count 31 (+ 7) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{3.9721 cm} x{13.2979 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Logic and Conditionals (cont)}} \tn % Row 3 \SetRowColor{LightBackground} and, or & {\bf{(and {\emph{item}}...)}} Evaluates its arguments until one returns nil (not-nil for {\bf{or}}), and returns the last value. \tn % Row Count 4 (+ 4) % Row 4 \SetRowColor{white} not & {\bf{(not {\emph{item}})}} Returns t if its argument is nil, or nil otherwise. Equivalent to null. \tn % Row Count 7 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{5.5264 cm} x{11.7436 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Input / Output}} \tn % Row 0 \SetRowColor{LightBackground} read & (read {[}stream{]}) Reads an atom or list from the serial input and returns it. If stream is specified the item is read from the specified stream. \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} print & (print item {[}stream{]}) Prints its argument, and returns its value. Strings are printed with quotation marks and escape characters followed by a newline. \tn % Row Count 12 (+ 6) % Row 2 \SetRowColor{LightBackground} princ & (princ item {[}stream{]}) Prints its argument, and returns its value. Characters and strings are printed without quotation marks or escape characters \tn % Row Count 18 (+ 6) % Row 3 \SetRowColor{white} pprint & (pprint item {[}stream{]}) Prints its argument, using the pretty printer, to display it formatted in a structured way. It returns no value \tn % Row Count 23 (+ 5) % Row 4 \SetRowColor{LightBackground} readline, writeline & (read-line {[}stream{]}) Reads characters from the serial input up to a newline character, and returns them as a string, excluding the newline. \tn % Row Count 29 (+ 6) % Row 5 \SetRowColor{white} writestring & (write-string string {[}stream{]}) Writes a string. If stream is specified the string is written to the stream. \tn % Row Count 33 (+ 4) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{5.5264 cm} x{11.7436 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Input / Output (cont)}} \tn % Row 6 \SetRowColor{LightBackground} format & (format output controlstring arguments*) Outputs its arguments formatted according to the format directives in the control string. (format t "The answer is \textasciitilde{}a" 42) The answer is 42 \tn % Row Count 7 (+ 7) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{2.5905 cm} x{14.6795 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Tests}} \tn % Row 0 \SetRowColor{LightBackground} null & {\bf{(null {\emph{item}})}} Returns t if its argument is nil, or nil otherwise. Equivalent to not. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} atom & {\bf{(atom {\emph{item}})}} Returns t if its argument is a single number, symbol, or nil. \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} listp & {\bf{(listp {\emph{item}})}} Returns t if its argument is a list. \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} consp & {\bf{(consp {\emph{item}})}} Returns t if its argument is a non-null list. \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{numberp} & {\bf{(numberp {\emph{item}})}} Returns t if its argument is a number. \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} \seqsplit{streamp} & {\bf{(streamp {\emph{item}})}} Returns t if the argument is a valid stream and nil otherwise. \tn % Row Count 15 (+ 3) % Row 6 \SetRowColor{LightBackground} eq & {\bf{(eq {\emph{item}} {\emph{item}})}} Tests whether the two arguments are the same {\bf{object}} and returns t or nil. Objects are eq if they are the same symbol, same character, equal numbers, or point to the same cons. Use {\bf{equal}} to compare strings. \tn % Row Count 23 (+ 8) % Row 7 \SetRowColor{white} equal & {\bf{(equal {\emph{item}} {\emph{item}})}} Tests whether the two arguments look the same when printed, and returns t or nil as appropriate. Note that they might not necessarily be the same object. Objects are equal if they are eq, have the same string representation, or have the same list structure. \tn % Row Count 32 (+ 9) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{2.5905 cm} x{14.6795 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Tests (cont)}} \tn % Row 8 \SetRowColor{LightBackground} \seqsplit{symbolp} & {\bf{(symbolp {\emph{item}})}} Returns t if the argument is a symbol and nil otherwise. \tn % Row Count 3 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{5.6991 cm} x{11.5709 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Characters}} \tn % Row 0 \SetRowColor{LightBackground} char & {\bf{(char {\emph{string}} {\emph{n}})}} Returns the nth character in a string, counting from zero. \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} char-code, code-char & {\bf{(char-code {\emph{character}})}} Returns the ASCII code for a character, as an integer. {\bf{code-char}} does the inverse. \tn % Row Count 9 (+ 5) % Row 2 \SetRowColor{LightBackground} characterp & {\bf{(characterp {\emph{item}})}} Returns t if the argument is a character and nil otherwise. \tn % Row Count 13 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{p{2.2451 cm} x{15.0249 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Strings and Lists}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{subseq} & {\bf{(subseq {\emph{string}} {\emph{start}} {[}{\emph{end}}{]})}} Returns a subsequence of a list or string. {\bf{(subseq '(0 1 2 3 4) 2 4) ⮕ (2 3) }} \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \seqsplit{search} & {\bf{(search pattern target)}} Returns the index of the first occurrence of pattern in target, which can be lists or strings, or nil if it's not found. Example: {\bf{(search "cat" "the cat sat")) ⮕ 4}} \tn % Row Count 10 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{3.454 cm} x{13.816 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{In-place Operations}} \tn % Row 0 \SetRowColor{LightBackground} setf & (setf place value {[}place value{]}*) Modifies an existing list by setting the position in the list specified by place to the result of evaluating value. (defvar xyz '(0 0 0)) xyz \textgreater{} (setf (nth 0 xyz) 90) 90 \textgreater{} (setf (nth 1 xyz) 45) 45 \textgreater{} xyz (90 45 0) \tn % Row Count 8 (+ 8) % Row 1 \SetRowColor{white} push, pop & (push item place) Modifies the value of place, which should be a list, to add item onto the front of the list, and returns the new list. The second argument place c \tn % Row Count 14 (+ 6) % Row 2 \SetRowColor{LightBackground} incf, decf & (incf place {[}number{]}) Adds one to the value of place, and returns the new value. \tn % Row Count 17 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{2.5905 cm} x{14.6795 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Iteration and Mapping}} \tn % Row 0 \SetRowColor{LightBackground} loop & {\bf{(loop {\emph{forms}}...)}} Loop executes its arguments repeatedly until one of them reaches a return form. {\bf{(loop (princ "\$") (if (= 0 (random 10)) (return))) ⮕ \$\$\$ }} \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} \seqsplit{return} & {\bf{(return {[}{\emph{value}}{]})}} Exits from a loop, dotimes, or dolist block. Returns value, or nil if no value is specified. \tn % Row Count 9 (+ 4) % Row 2 \SetRowColor{LightBackground} \seqsplit{dolist} & {\bf{(dolist ({\emph{var}} {\emph{list}} {[}{\emph{result}}{]}) {\emph{form}}...)}} Sets the local variable var to each element of list in turn, and executes the forms. It then returns result, or nil if result is omitted. \tn % Row Count 15 (+ 6) % Row 3 \SetRowColor{white} \seqsplit{dotimes} & {\bf{(dotimes ({\emph{var}} {\emph{number}} {[}{\emph{result}}{]}) *form..)}} Executes the forms number times, with the local variable var set to each integer from 0 to number-1 in turn. It then returns result, or nil if result is omitted. {\bf{(dotimes (x 10) (princ x)) ⮕ 0123456789}} \tn % Row Count 23 (+ 8) % Row 4 \SetRowColor{LightBackground} mapc & {\bf{(mapc {\emph{function}} {\emph{list1}} {[}{\emph{list}}{]}...)}} Applies the function to each element in one or more lists, ignoring the results. It returns the first list argument. \tn % Row Count 28 (+ 5) % Row 5 \SetRowColor{white} \seqsplit{mapcar} & {\bf{(mapcar {\emph{function}} {\emph{list}} ...)}} Applies the function to each element in one or more lists, and returns the resulting list. The function can be a built-in function; for example: {\bf{(mapcar * '(1 2 3) '(4 5 6) '(7 8 9)) ⮕ (28 80 162)}} \tn % Row Count 36 (+ 8) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{2.5905 cm} x{14.6795 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Iteration and Mapping (cont)}} \tn % Row 6 \SetRowColor{LightBackground} \seqsplit{mapcan} & (mapcan function list1 {[}list2{]}*) Applies the function to each element in one or more lists. The results should be lists, and these are appended together to give the value returned by mapcan. \tn % Row Count 6 (+ 6) % Row 7 \SetRowColor{white} progn & (progn form*) Evaluates several forms grouped together into a block, and returns the result of evaluating the last form. \tn % Row Count 10 (+ 4) % Row 8 \SetRowColor{LightBackground} assoc & (assoc key list) Looks up a key in an association list of (key . value) pairs, and returns the matching pair, or nil if no pair is found. \tn % Row Count 15 (+ 5) % Row 9 \SetRowColor{white} \seqsplit{member} & (member item list) Searches for an item in a list, using eq, and returns the list starting from the first occurrence of the item, or nil if it is not found. \tn % Row Count 20 (+ 5) % Row 10 \SetRowColor{LightBackground} apply & (apply function list) Returns the result of evaluating the function specified by the first argument with the list of arguments specified by the second parameter. \tn % Row Count 25 (+ 5) % Row 11 \SetRowColor{white} eval & (eval form{\emph{) Evaluates its argument. ⮕ Example: {\bf{(eval (list '}} 7 8)) 56}} \tn % Row Count 28 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{3.454 cm} x{13.816 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{uLisp Special Arduino Interface}} \tn % Row 0 \SetRowColor{LightBackground} millis & (millis) Returns the time in milliseconds that uLisp has been running. On 8/16-bit versions of uLisp this is a signed 16-bit number, so after 32.767 seconds the number will wrap around from 32767 to -32768. In 32-bit versions of uLisp this is a signed 32-bit number which will wrap around after about 25 days. \tn % Row Count 10 (+ 10) % Row 1 \SetRowColor{white} \seqsplit{for-millis} & (for-millis ({[}number{]}) form*) Executes the forms and then waits until a total of number milliseconds have elapsed. It returns the total number of milliseconds taken. \tn % Row Count 16 (+ 6) % Row 2 \SetRowColor{LightBackground} delay & (delay number) Delays for a specified number of milliseconds. \tn % Row Count 18 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \end{document}