Life of the IT-Drummer

A web log from Tobias Rusås Olsen.

How some basic LISP-functions are defined.

Today, Pål gave me a link to this lisp-file, which shows how some basic LISP-functions are defined. For those used to “first” and “rest”, those are called “car” and “cdr”, guess that was “the shit” in the 60’s. It’s kinda interesting seeing how functions you take for granted like “and”, actually is defined by other lisp functions. Here’s the code for “and”, for those who’s interested:

(defun and. (x y)
(cond (x (cond (y 't) ('t '())))
('t '())))

As you can see, it’s pretty much made out of the function cond. Great!

RSS 2.0 | Trackback | Comment

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">