192x Filetype PDF File size 0.03 MB Source: cseweb.ucsd.edu
An Introduction to LISP ✔ How to interact with LISP: sdcc5.ucsd.edu% cl Allegro CL 4.1 [SPARC; R1] (4/9/93 17:00) Copyright (C) 1985-1992 Franz Inc., Berkeley CA, USA. ;; Optimization settings; safety 1, space 1, speed 1, debug 2 ;; For a complete description of all compiler switches ;; evaluate (EXPLAIN-COMPILER-SETTINGS). USER(1): ✔ cl stands for Common LISP, now the standard dialect of LISP ✔ (Note the semicolons ; In LISP programs, comments start with a semicolon and go to the end of the line) LANGUAGES FOR AI Page 1 of 27 LEC 2 Interacting with LISP ✔ LISP is an interactive language ✗ (Common LISP also has a good compiler, and can do offline computations) ✔ When you invoke LISP, the lisp interpreter enters a read - eval - print loop ✔ You type an expression in response to the prompt, and ... ✗ LISP reads in the expression you typed ✗ LISP evaluates it ✗ LISP prints the result of the evaluation, and prompts for the next input ✔ (Note: in fact, read, eval, print are names of builtin LISP functions...) LANGUAGES FOR AI Page 2 of 27 LEC 2 Interacting with LISP ✔ What is the result of LISP’s evaluation process? ✔ It depends on the expression that is being evaluated ✔ Expressions are of two types: ✗ atoms ✗ lists ✔ Atoms are of two types: ✗ constants: • numbers: 27, 3.14, 5/8, 1.0e26, etc. • strings: “A string”, “another one”, etc. • characters: #\a, #\A, #\b, etc. ✗ symbols: foobar, FooBaR, hyphenated-symbol, +, etc. ✔ A list is represented as ( < zero or more atoms or lists > ) ✗ examples of lists: () (item1 item2 item3) (foo (bar baz)) (+ 3 4) (() (()())) LANGUAGES FOR AI Page 3 of 27 LEC 2 Expression types in LISP symbol atom number constant string character s-expressions the empty list list cons LANGUAGES FOR AI Page 4 of 27 LEC 2
no reviews yet
Please Login to review.