Docsity

Lisp Notes: An Introduction to the Functional Programming Language, Study notes of Programming Languages

Toggle sidebar
bg1
Intro Lisp Notes
1. Touretzky book - available online, there’s a link to it on the course web-
page.
1a. web page resources
2. History Originally developed in the late 50s by John McCarthy.
Equally capable of numeric computation and symbolic computation.
Primarily adopted as an AI language. Also used in AutoCAD, Visio,
Emacs, Yahoo! Store, etc.
ANSI standard developed in 1994 - served to reunite different implemen-
tations.
3. Implementations: clisp, cmucl, allegro.
Using lisp with emacs.
4. Basics of usage: starting the interpreter.
5. Functional programming
a function maps a set of inputs to an output.
No side effects
Can be treated as a black box.
Examples: +, -, *, -, sqrt, abs
6. Predicates.
A predicate is a special type of function.
Predicates map from inputs to true or false
They are used to test conditions, types, equality, etc.
Convention: end with ’p’.
e.g. numberp, symbolp, consp, evenp, oddp, equal
Not - maps non-nil to nil and nil to t.
7. data types
•Numbers
integers
floating point numbers - note on precision in lisp.
ratios, fractions
•Symbols
named after English words
Any combination of letters and numbers.
Serve to represent some non-numeric value.
t and nil - special symbols.
quote.
1
pf2

Partial preview of the text

Download Lisp Notes: An Introduction to the Functional Programming Language and more Study notes Programming Languages in PDF only on Docsity!

Intro Lisp Notes

  1. Touretzky book - available online, there’s a link to it on the course web- page. 1a. web page resources
  2. History Originally developed in the late 50s by John McCarthy. Equally capable of numeric computation and symbolic computation. Primarily adopted as an AI language. Also used in AutoCAD, Visio, Emacs, Yahoo! Store, etc. ANSI standard developed in 1994 - served to reunite different implemen- tations.
  3. Implementations: clisp, cmucl, allegro. Using lisp with emacs.
  4. Basics of usage: starting the interpreter.
  5. Functional programming

a function maps a set of inputs to an output. No side effects Can be treated as a black box. Examples: +, -, *, -, sqrt, abs

  1. Predicates. A predicate is a special type of function. Predicates map from inputs to true or false They are used to test conditions, types, equality, etc. Convention: end with ’p’. e.g. numberp, symbolp, consp, evenp, oddp, equal Not - maps non-nil to nil and nil to t.
  2. data types
    • Numbers integers floating point numbers - note on precision in lisp. ratios, fractions
    • Symbols named after English words Any combination of letters and numbers. Serve to represent some non-numeric value. t and nil - special symbols. quote.
  • Lists A list is composed of cons cells. A typical cons cell has a car and a cdr List notation: (a b c d) Box-and-arrow notation. Well-formed lists - last cdr points to nil. Nested Lists. Length of Lists. - (length ’(a (b c) d)) → 3. nil as the empty list. list equality. (a b (c d)) != (a (b c) d) first, second, third, rest, car, cdr. (car and cdr of nil are nil)
  1. Building lists:
  • Cons: Cons creates a cons cell, where the first argument is the car and the second the cdr. e.g. (cons ’a ’b) → (a. b) (cons b nil) → (b) (cons a (cons b nil)) → (a b)
  • List: constructs a well-formed list from a set of arguments. (list ’a ’b ’c) → (a b c) (list ’(a b) c ’(d e)) → ((a b) c (d e)) (list nil) → (nil)