A Little Lisp

Embed Size (px)

DESCRIPTION

Presentation on Lisp given by James Ladd to the Melbourne Patterns group in September 2008

Text of A Little Lisp

  • 1. (A Little LISP ) By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia
  • 2. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia WHAT ?
  • 3. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia The greatest single programming language ever designed. Alan Kay
  • 4. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia John McCarthy Created LISP
  • 5. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia John McCarthy Recursive Functions of Symbolic Expressions and Their Computation by Machine
  • 6. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia John McCarthy In 1958 Created LISP
  • 7. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia LISP (quote (+ 1 2)) (+ 1 2)
  • 31. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia (atom x ) returns t if x is an atom, otherwise () >(atom 'a) t >(atom '(a b c)) ()
  • 32. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia (eq x y ) returns t if x and y are same atom or both (), otherwise () >(eq 'a 'a) >(eq '() '()) t t >(eq 'a 'b) ()
  • 33. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia (car x ) returns first element of value of x >(car '(a b c)) a >(car '('(foo) bar baz)) (foo)
  • 34. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia (cdr x ) returns everything after the first element of value of x >(cdr '(a b c)) (b c) >(cdr '('(foo) bar baz)) (bar baz)
  • 35. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia (cons x y ) returns a list containing value of x followed by value of y >(cons 'a '(b c)) (a b c) >(car (cons 'a '(b c))) (b c)
  • 36. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia
  • 37. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia (cond ( p1 e1 )...( p n e n )) The p expressions are evaluated in order until one returns t . When one is found, the value of the corresponding e expression is returned as the value of the whole cond expression.
  • 38. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia (cond ( p1 e1 )...( p n e n )) >(cond ((eq 'a 'b) 'first) ((atom 'a) 'second)) second
  • 39. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia (cond ( p1 e1 )...( p n e n )) (cond ( x y ) ('t z )) is equivalent to if x then y else z
  • 40. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia Recommended Reading The Little Lisper ANSI Common Lisp
  • 41. A Little LISP, By James Ladd http://www.jamesladdcode.com with portions from The Roots Of Lisp, by Paul Graham All images iStockPhoto or Wikipedia Some real code ...
  • 42.