Last modified on 18 November 2010, at 11:31

Lisp Programming/Overview

An overview, eh? So, very quickly, here are the nuts and bolts;

(defun ! (x)          ; Defines a factorial function denoted by the exclamation mark symbol. 
  (if (> x 0)
      (* x (! (- x 1)))
      1))

tail-end recursion... creating a factorial function.

(setf this '(hello world opps goodbye))
(car this) => hello
(cdr this) => (world opps goodbye)
(cadr this) => world
(cdar this) => probably an error

lists, what lisp is named for, and a few functions that get at lisp.

if you must, you can also do:

(setf ... same...
(first this) => hello
...
(second this) => world

but you can't compose it (ex have doing car cdr be cadr)

and yay, macros...

(defmacro when (cond &body body)
   (if (cond)
      (progn ,@body)))

by this time, we're kind of getting in over our heads, but hey!

(defun do-nothing (anargument :key akeywordargument :opt anoptionalargument :rest everythingelseinalist))

I couldn't figure out a way to incorporate all four types of function arguments into one (you can't, and it's generally a bad idea to combine more than 2 of them.)

There's also the CLOS (common lisp object system) and a whole lot of other stuff that you probably should know about, but if you want to really, you better work through a good tutorial.

So hey, that's kind of a rough gist of Lisp. Have fun lisping!