Lisp Resources and Links
Total Page:16
File Type:pdf, Size:1020Kb
Lisp Resources and Links
Common Lisp at UH
Using emacs:
Create a file in your home directory called .emacs if you don't already have one. Put the following lines in that file:
(setq inferior-lisp-program "/opt/acl60/alisp") (global-set-key "\C-x\C-l" `run-lisp) (global-set-key "\C-xd" `lisp-eval-defun) (global-set-key "\C-x\C-d" `lisp-eval-defun-and- go)
(add-to-list 'load-path "~ics313/public_html/slime-2.0/") ; your SLIME directory (require 'slime) (slime-setup)
To start Lisp within SLIME, type M-x slime This will start SLIME and an inferior lisp process in your buffer. The SLIME manual and files can be found at ICS 313 slime directory To start a Lisp process from within emacs, type C-x C-l or Meta-X run-lisp Many more commands are available in the unix/emacs help files. For running Lisp as an inferior process to Emacs, put this in your .emacs file. o A list of emacs/acl key bindings
Without emacs: acl_hints.html How to run Common Lisp on UH Uhix
o Save this in your .clinit.cl file (from Franz) o Or this version .clinit.cl (from David Chin)
Call LISP by typing “alisp” at UH Unix prompt. It should be in /opt/acl60/alisp. Add it to your path variable in .cshrc and then type at unix prompt: source .cshrc
“alisp” is a shortcut for Allegro Common LISP. “ Hello world” example in many flavors:
CL-USER> “hello world” [what does this do?] CL-USER> (format t “hello world”) [format it] CL-USER> (defun hello-world () (format t “hello world”) [what does this do?] CL-USER> now run hello-world function! How will you do that? Now save the function into file hello.lisp. CL-USER> (load “hello.lisp”) alternate commands are :ld filename and :cl filename, filename without .lisp extension. CL-USER> (hello-world) [what do you expect to see here?] alisp can be interpreted or compiled, so when the interpreter encounters an error, it will automatically put you into debugger.
To get out of debugger, type :exit.
DEBUGGER: Page 284 of Touretzky is not quite applicable to UH version of alisp. The principles are presented well. The specific syntax needs to be looked up. http://www.cs.utexas.edu/users/mooney/cs351/allegro-tips.html http://www.cs.colostate.edu/~howe/handouts/lisp.html http://www.franz.com/support/documentation/7.0/doc/debugging.htm Very comprehensive manual.
Put the information in the Header line for lisp files for lisp assignment files. For examples of functions, see selection statements selection.lisp, recursive functions recurse.lisp beer.lisp using princ and terpri, beer-format.lisp same function using format for output or selection.lisp
Lisp at home
Lisp in a box http://www.gigamonkeys.com/book/lispbox/ Practical Common Lisp textbook and code http://www.gigamonkeys.com/book/
Common Lisp Resources Ansi common lisp specification online from Xanalys/Lispworks http://www.lispworks.com/reference/HyperSpec/Front/Contents.htm "Common Lisp: A gentle introduction to Symbolic Computation" by David S. Touretzky (pdf) (local copy) http://www.franz.com/support/documentation/5.0.1/ansicl/ansicl.htm Complete specification for Common Lisp in HTML http://www.lispworks.com/reference/HyperSpec/Front/index.htm from Xanalys. Put the following information in the header of your lisp files Practical Lisp Programming Online pages http://www.cliki.net/Practical%20Lisp %20Programming Online Tutorial material list from the Association of Lisp Users (http://www.lisp.org/alu/res-lisp-education) Lisp Resource Kit - with bootable Linux CD image (700 MB) is available at: http://www.google.com/url?sa=U&start=6&q=http://www.common- lisp.net/project/lisp-res-kit/&e=912
Example programs
Towers of hanoi program in lisp (Hanoi.lisp) Lisp structure drawing program (sdraw.lisp) describe function The function describe takes a symbol argument (quoted function name) and returns the documentation string and other properties of the symbol. For example (describe 'sumcube) ==> SUMCUBE is a SYMBOL. It is unbound. It is INTERNAL in the COMMON-LISP-USER package. Its function binding is # The function takes arguments (X Y) Its property list has these indicator/value pairs: EXCL::%FUN-DOCUMENTATION "Returns the sum of arguments cubed" CL-USER(28):
Example programs in Common Lisp are available in the assignments directory. Lisp includes recursion, iteration, the towers of Hanoi problem, the N-Queens problem, and state space searches in the sssearch directory. Note: the concatenate function in Common Lisp takes any number of arguments (in contrast to princ) and returns them in a specified format, eg. (concatenate (quote string) "A" " " "C" " " "B" ) ==> "A C B" which can be passed to princ. To convert a number to a string (for use in concatenate, for example), use (princ-to-string 99) ==> "99" SIMPLE YES-NO games, Ch.9 in Touretzky. Tic-tac-toe, section 10.6 in Touretzky.
Common Lisp for home
Xanalys Lispworks - commercial and trial versions of common lisp -- http://www.lispworks.com Franz, Inc. - commercial and trial versions of common lisp -- http://www.franz.com ANSI Common Lisp compiler, debugger, and interpreter -- CLISP. Free implementation of Common Lisp from Carnegie Mellon -- CMUCL. GNU compiler and interpreter for common lisp -- GCL
General Lisp Programming Resources
A discussion of Lisp for C programmers http://www2.hawaii.edu/~nreed/ics313/lisp/lispbook.pdf (pdf) (postscript) http://www.DynamicLearningCenter.com -- A new resource from Franz, Inc for learning Common Lisp interactively. Common Lisp Resources on the Web, Amant & Young, Intelligence, V. 12, No. 3, pp. 21-23 (handout) Basic Lisp Techniques (pdf) Adaptive Software Article Tutorial on Good Lisp Programming Style, Peter Norvig (postscript) or (pdf) Loving Lisp - The Savy Programmer's Secret Weapon by Mark Watson - book + code html to download Text version of Richard Stallman's historical/hysterical talk/flame at the International Lisp Conference in 2002 in SanFrancisco. It is at http://www.gnu.org/gnu/rms-lisp.html Examples of defining and using structures Common Lisp Object System examples
Lisp compared to other languages
http://userpages.umbc.edu/~bcorfm1/C++-vs-Lisp.html
Scheme Resources
http://userpages.umbc.edu/~bcorfm1/C++-vs-Lisp.html The 90 Minute Scheme to C compiler http://www.iro.umontreal.ca/%7Eboucherd/mslug/meetings/20041020/minutes- en.html from '(Montreal Scheme/Lisp User Group) 20/10/2004 Meeting Marc Feeley gave us another really good presentation. It was more technical than the previous ones, but it was definitely worth it. (I think this may set the tone for future presentations... we'll see!) Marc showed us how to write a simple Scheme to C compiler, in Scheme. In only 90 minutes! And although not supporting the whole Scheme standard, the compiler supports fully optimized proper tail calls, continuations, and (of course) full closures. The compiler is implemented using two important compilation techniques for functional languages: closure conversion and CPS-conversion. The presentation is available in PDF format. The source code of the whole compiler is available here, as well as a few test programs: test1.scm, test2.scm, and test3.scm. http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs.html
Intelligent Agent Programming in Lisp
Intelligent Agents - Chapter 2 of Russell and Norvig’s text "Artificial Intelligence: A Modern Approach". (pdf). Overview of R & N Agent code from AI, A Modern Approach link LISA - Intelligent Software Agents for Common Lisp -- LISA environment.