100 likes | 261 Views
Lisp Environment Setup. Hongliang Gao COP 4020 9/13/06. Contents. Common Lisp Two choices (SBCL and Lispworks) SBCL – Basics Predefined Functions Example. Common Lisp. What is common lisp? A dialect of the Lisp programming language Standardized by ANSI X3.226-1994
E N D
Lisp Environment Setup Hongliang Gao COP 4020 9/13/06
Contents • Common Lisp • Two choices (SBCL and Lispworks) • SBCL – Basics • Predefined Functions • Example
Common Lisp • What is common lisp? • A dialect of the Lisp programming language • Standardized by ANSI X3.226-1994 • Developed to standardize the divergent variants of Lisp which predated it. • It is not an implementation but rather a language specification. • Common Lisp is a multi-paradigm programming language • Imperative, functional and object-oriented. • Reference: http://en.wikipedia.org/wiki/Common_lisp
Common Lisp cont. • Scheme vs. Common Lisp
Two choices (SBCL and Lispworks) • Using SBCL on Olympus • http://sbcl.sourceforge.net/ • Local Common Lisp setup (Lispworks) • http://www.lispworks.com/ • Download: http://www.lispworks.com/downloads/index.html
SBCL – Basics • Connect to Olympus • http://www.ucf.edu/pidandnid/nid.html • http://www.acs.ucf.edu/documents/handouts/Olympus_Info.pdf • If [BACKSPACE] is causing ^? to be inserted into the string, then hitting Ctrl-H should act as backspace. • At the prompt, the lisp environment can be accessed by entering sbcl • This will put you into the command line interpreter. • Exit (Ctrl+D) • From debug mode (prompt is “0[5]”) to the prompt “*” • Keep pressing Ctrl+D • Exit sbcl (or use (quit))
SBCL – Basics cont. • Load outside files, or define/call functions within the interpreter. • sbcl --load test.lisp • (load “test.lisp”) • Use of Quote (‘) • http://www.apl.jhu.edu/~hall/lisp/Lisp-Quote-Hints.text
Predefined Functions • Limited functions you can use in the homework • Reference: • ANSI and GNU Common Lisp Document • http://www.cs.queensu.ca/software_docs/gnudev/gcl-ansi/gcl_toc.html • Variable • Define: (defvar var-name value) • (defvar a 100) • Assign: (setq var-name1 value1 var-name2 value2 … ) • (setq a ‘(a b c) b 100)
Predefined Functions cont. • CAR • CDR • COND • NULL • CONS • DEFUN • LIST • list returns a list containing the supplied objects. • (list ‘a ‘b ‘(c d)) => (A B (C D)) • ATOM • LISTP • Returns true if object is of typelist; otherwise, returns false. • EQ / EQL / EQUAL • Implementation dependent (so you may get different results than which in the ANSI document) • For safety, use EQUAL
Example • Define a function which picks numbers less than 100 of a list.