1 / 10

Lisp Environment Setup

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

jered
Download Presentation

Lisp Environment Setup

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lisp Environment Setup Hongliang Gao COP 4020 9/13/06

  2. Contents • Common Lisp • Two choices (SBCL and Lispworks) • SBCL – Basics • Predefined Functions • Example

  3. 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

  4. Common Lisp cont. • Scheme vs. Common Lisp

  5. 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

  6. 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))

  7. 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

  8. 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)

  9. 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

  10. Example • Define a function which picks numbers less than 100 of a list.

More Related