% latex generated by the script '/home/project-web/bumble/cgi-bin/text2latex.cgi' % with help from the sed script 'text2latex.sed' % query string: 'books/lisp/lisp-book' % sFileName= 'lisp-book' % sDirName = 'books/lisp' % sName = '' --> % latex by http://bumble.sourceforge.net/scripts/text2latex.sed % this script is a work in progress \documentclass[11pt]{article} \usepackage[hmargin=2cm, vmargin=2cm]{geometry} \usepackage{url} \usepackage{hyperref} \begin{document} \\&\\& The lisp Booklet This booklet is about the Common Lisp programming language and in particular, the gcl implementation of that. Lisp is a 'list processing language'. In lisp braces define a list. The first element of the list is often a function. Lisp is the macro language of the 'emacs' unix text editor. @@ \url{http://www.gigamonkeys.com/book/} an introductory book about common lisp * evaluate 2 + 3 using the '+' function >> (+ 2 3) * define a new lisp function >> (defun hello-world () (format t "hello, world")) * call the 'hello-world' function >> (hello-world) * load lisp code contained in the file 'hello.lisp' >> (load "hello.lisp") * create a list of numbers (the list is returned by this function) >> (list 1 2 3) Note the similarity of this with the tcl list command (which, no doubt was inspired by lisp) * create a type of associative array (or 'plist') >> (list :a 1 :b 2 :c 3) The colon character is important here. * return the element associated with the ':a' element >> (getf (list :a 1 :b 2 :c 3) :a) * a function which creates a basic data record using a plist ------------------------------------------------------------ (defun make-cd (title artist rating ripped) (list :title title :artist artist :rating rating :ripped ripped)) ,,, * make one record using the above function >> (make-cd "Roses" "Kathy Mattea" 7 t) * create an empty global variable '*db*' >> (defvar *db* nil) The *s are a naming convention for global variables * a function to add an element to a global list variable >> (defun add-record (cd) (push cd *db*)) * a function to read a value from the user ------------------------------------------ (defun prompt-read (prompt) (format *query-io* "\\$\\verb|~|a: " prompt) (force-output *query-io*) (read-line *query-io*)) ,,, * if clause in lisp is known as a 'special operator' >> (if x (format t "yes") (format t "no")) \end{document} %end generated latex