\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{Andre Boechat (boechat107)} \pdfinfo{ /Title (common-lisp.pdf) /Creator (Cheatography) /Author (Andre Boechat (boechat107)) /Subject (Common Lisp 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}{073021} \definecolor{LightBackground}{HTML}{F7F8F8} \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{Common Lisp Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Andre Boechat (boechat107)} via \textcolor{DarkBackground}{\uline{cheatography.com/54058/cs/14524/}}} \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}Andre Boechat (boechat107) \\ \uline{cheatography.com/boechat107} \\ \uline{\seqsplit{boechat107}.github.io/} \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 30th January, 2018.\\ Updated 21st February, 2018.\\ 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{multicols*}{2} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Numbers}} \tn % Row 0 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_parse\_.htm\#parse-integer"\}\}`parse-integer`\{\{/link\}\} & Parses an integer from a string \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} \{\{link="http://clhs.lisp.se/Body/f\_floorc.htm\#floor"\}\}`floor`\{\{/link\}\}, \{\{link="http://clhs.lisp.se/Body/f\_floorc.htm\#ceiling"\}\}`ceiling`\{\{/link\}\} & Truncates toward negative/positive infinity \tn % Row Count 13 (+ 8) % Row 2 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_floorc.htm\#round"\}\}`round`\{\{/link\}\} & Rounds to the nearest integer \tn % Row Count 17 (+ 4) % Row 3 \SetRowColor{white} \{\{link="http://clhs.lisp.se/Body/a\_mod.htm\#mod"\}\}`mod`\{\{/link\}\}, \{\{link="http://clhs.lisp.se/Body/f\_mod\_r.htm\#rem"\}\}`rem`\{\{/link\}\} & Modulus/remainder of a truncating division \tn % Row Count 24 (+ 7) % Row 4 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_1pl\_1\_.htm\#1PL"\}\}`1+`\{\{/link\}\}, \{\{link="http://clhs.lisp.se/Body/f\_1pl\_1\_.htm\#1-"\}\}`1-`\{\{/link\}\} & Returns a new value (inc/dec)remented by a number \tn % Row Count 31 (+ 7) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Numbers (cont)}} \tn % Row 5 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/m\_incf\_.htm\#incf"\}\}`incf`\{\{/link\}\}, \{\{link="http://clhs.lisp.se/Body/m\_incf\_.htm\#decf"\}\}`decf`\{\{/link\}\} & \{\{fa-exclamation-circle\}\} Macros to (inc/dec)rement in place \tn % Row Count 7 (+ 7) % Row 6 \SetRowColor{white} \{\{link="http://clhs.lisp.se/Body/f\_eq\_sle.htm\#EQ"\}\}`=`\{\{/link\}\}, \{\{link="http://clhs.lisp.se/Body/f\_eq\_sle.htm\#SLEQ"\}\}`/=`\{\{/link\}\} & Mathematical value equality (types ignored) \tn % Row Count 14 (+ 7) % Row 7 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_eq\_sle.htm\#GT"\}\}`\textgreater{}`\{\{/link\}\}, \{\{link="http://clhs.lisp.se/Body/f\_eq\_sle.htm\#GTEQ"\}\}`\textgreater{}=`\{\{/link\}\}, \{\{link="http://clhs.lisp.se/Body/f\_eq\_sle.htm\#LT"\}\}`\textless{}`\{\{/link\}\}, \{\{link="http://clhs.lisp.se/Body/f\_eq\_sle.htm\#LTEQ"\}\}`\textless{}=`\{\{/link\}\} & Order comparison \tn % Row Count 28 (+ 14) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.8 cm} p{0.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Characters}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Strings}} \tn % Row 0 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_format.htm\#format"\}\}`format`\{\{/link\}\} & Returns a formatted output string when the {\emph{destination}} is `nil` \tn % Row Count 4 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.08 cm} x{3.92 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Sequences}} \tn % Row 0 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_elt.htm\#elt"\}\}`elt`\{\{/link\}\} & Access elements with an integer index \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{\{\{link="http://clhs.lisp.se/Body/f\_length.htm\#length"\}\}`length`\{\{/link\}\}} \tn % Row Count 6 (+ 2) % Row 2 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_countc.htm\#count"\}\}`count`\{\{/link\}\} & Count the appearances of an element \tn % Row Count 10 (+ 4) % Row 3 \SetRowColor{white} \{\{link="http://clhs.lisp.se/Body/f\_find\_.htm\#find"\}\}`find`\{\{/link\}\} & Finds an item or returns `nil` \tn % Row Count 14 (+ 4) % Row 4 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_pos\_p.htm\#position"\}\}`position`\{\{/link\}\} & The first index of an element \tn % Row Count 18 (+ 4) % Row 5 \SetRowColor{white} \{\{link="http://clhs.lisp.se/Body/f\_rm\_rm.htm\#remove"\}\}`remove`\{\{/link\}\} & Removes all the occurrences of an item \tn % Row Count 22 (+ 4) % Row 6 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_sbs\_s.htm\#substitute"\}\}`substitute`\{\{/link\}\} & Replaces all occurrences of an item \tn % Row Count 26 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Lists}} \tn % Row 0 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_mapc\_.htm\#mapcar"\}\}`mapcar`\{\{/link\}\} & Successively applies a function to each element of a list \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \{\{link="http://clhs.lisp.se/Body/f\_mapc\_.htm\#maplist"\}\}`maplist`\{\{/link\}\} & Like `mapcar`, but its function receives a {\bf{cons}} cell instead of its element (therefore, the function has access to the rest of the list) \tn % Row Count 11 (+ 7) % Row 2 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_mapc\_.htm\#mapcan"\}\}`mapcan`\{\{/link\}\} & Like `mapcar`, but the results are combined into a list \tn % Row Count 15 (+ 4) % Row 3 \SetRowColor{white} \{\{link="http://clhs.lisp.se/Body/f\_mapc\_.htm\#mapcon"\}\}`mapcon`\{\{/link\}\} & Like `mapcan`, but applied to `maplist` \tn % Row Count 19 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.8 cm} p{0.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Vectors}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.8 cm} p{0.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Hash Tables}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.48 cm} x{5.52 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Things to remember}} \tn % Row 0 \SetRowColor{LightBackground} Object Oriented & All values in a Common Lisp program are instances of some {\bf{class}}. Furthermore, all classes are organized into a single hierarchy rooted at the class `T`. \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} Starting a project & \{\{link="http://boechat107.github.io/2017-11/getting-started-with-common-lisp/"\}\}SBCL and Quicklisp installation\{\{/link\}\} and a \{\{link="https://github.com/boechat107/cl-project-template"\}\}project template\{\{/link\}\} \tn % Row Count 14 (+ 8) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Equality}} \tn % Row 0 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_eq.htm\#eq"\}\}`eq`\{\{/link\}\} & Object identity (don't use with numbers or chars) \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \{\{link="http://clhs.lisp.se/Body/a\_eql.htm\#eql"\}\}`eql`\{\{/link\}\} & \{\{fa-thumbs-up\}\} Considers equivalent two objects of the same class with the same numeric or char value \tn % Row Count 9 (+ 6) % Row 2 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_equal.htm\#equal"\}\}`equal`\{\{/link\}\} & Lists with the same structure and contents, strings with the same characters \tn % Row Count 13 (+ 4) % Row 3 \SetRowColor{white} \{\{link="http://clhs.lisp.se/Body/f\_equalp.htm\#equalp"\}\}`equalp`\{\{/link\}\} & Ignores differences in case or in numerical type (`1 == 1.0`) \tn % Row Count 17 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Functions}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{\{\{link="http://clhs.lisp.se/Body/m\_defun.htm\#defun"\}\}`defun`\{\{/link\}\}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \{\{link="http://clhs.lisp.se/Body/a\_lambda.htm\#lambda"\}\}`lambda`\{\{/link\}\} & Returns an anonymous function \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/s\_ret\_fr.htm\#return-from"\}\}`return-from`\{\{/link\}\} & Immediately returns a value from a function (or a \{\{link="http://clhs.lisp.se/Body/s\_block.htm\#block"\}\}`block`\{\{/link\}\}) \tn % Row Count 12 (+ 6) % Row 3 \SetRowColor{white} \{\{link="http://clhs.lisp.se/Body/f\_funcal.htm\#funcall"\}\}`funcall`\{\{/link\}\} & Invokes a function from a function object \tn % Row Count 16 (+ 4) % Row 4 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_apply.htm\#apply"\}\}`apply`\{\{/link\}\} & Works like `funcall`, but receives the arguments as a list \tn % Row Count 20 (+ 4) % Row 5 \SetRowColor{white} \{\{link="http://clhs.lisp.se/Body/03\_da.htm\#AMoptional"\}\}`\&optional`\{\{/link\}\}, \{\{link="http://clhs.lisp.se/Body/03\_da.htm\#AMkey"\}\}`\&key`\{\{/link\}\}, \{\{link="http://clhs.lisp.se/Body/03\_da.htm\#AMrest"\}\}`\&rest`\{\{/link\}\}, \{\{link="http://clhs.lisp.se/Body/03\_da.htm\#AMallow-other-keys"\}\}`\&allow-other-keys`\{\{/link\}\} & Different ways to capture function arguments \tn % Row Count 36 (+ 16) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Standard Control Constructs}} \tn % Row 0 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/s\_if.htm\#if"\}\}`if`\{\{/link\}\} & The {\emph{else}} form is optional \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \{\{link="http://clhs.lisp.se/Body/m\_when\_.htm\#when"\}\}`when`\{\{/link\}\} & Like `if`, but returns `nil` if the condition is {\emph{falsy}} and evaluates multiple body forms \tn % Row Count 8 (+ 5) % Row 2 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/m\_when\_.htm\#unless"\}\}`unless`\{\{/link\}\} & Like `when`, but executes its body only when the condition is {\emph{falsy}} \tn % Row Count 12 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{IO}} \tn % Row 0 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_format.htm\#format"\}\}`format`\{\{/link\}\} & Produces formatted output to {\emph{stdout}} when the {\emph{destination}} is `t` \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{\{\{ac\}\}{\bf{`format` language}}} \tn % Row Count 5 (+ 1) % Row 2 \SetRowColor{LightBackground} `\textasciitilde{}a`, `\textasciitilde{}s`, & Interpolate argument in human readable format; interpolate as {\emph{Lisp}} readable \tn % Row Count 9 (+ 4) % Row 3 \SetRowColor{white} `\textasciitilde{}\%`, `\textasciitilde{}\&` & Newline; newline if not at the beginning of a line \tn % Row Count 12 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Object-Oriented}} \tn % Row 0 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/m\_defgen.htm\#defgeneric"\}\}`defgeneric`\{\{/link\}\} & Defines an abstract operation ({\emph{polymorphism}}) \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \{\{link="http://clhs.lisp.se/Body/m\_defmet.htm\#defmethod"\}\}`defmethod`\{\{/link\}\} & Defines an implementation of a generic function \tn % Row Count 8 (+ 4) % Row 2 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_call\_n.htm\#call-next-method"\}\}`call-next-method`\{\{/link\}\} & Similar to an invocation to a super-class method \tn % Row Count 13 (+ 5) % Row 3 \SetRowColor{white} \{\{link="http://clhs.lisp.se/Body/m\_defcla.htm\#defclass"\}\}`defclass`\{\{/link\}\} & New named class; some slot options are: `:reader`, `:writer`, `:accessor`, `:initarg`, `:initform`, `:documentation`, `:allocation` \tn % Row Count 20 (+ 7) % Row 4 \SetRowColor{LightBackground} \{\{link="http://clhs.lisp.se/Body/f\_slt\_va.htm\#slot-value"\}\}`slot-value`\{\{/link\}\} & Returns the value of slot in the object ({\bf{`setf`}}-able) \tn % Row Count 24 (+ 4) % Row 5 \SetRowColor{white} \{\{link="http://clhs.lisp.se/Body/m\_w\_slts.htm\#with-slots"\}\}`with-slots`\{\{/link\}\}, \{\{link="http://clhs.lisp.se/Body/m\_w\_acce.htm\#with-accessors"\}\}`with-accessors`\{\{/link\}\} & Binds a slot/accessor to a symbol that can be used in its body \tn % Row Count 33 (+ 9) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}