This is a read-only archive!

Baby steps

My first pathetic program in lisp:

(defun fib (x) 
  (if (and (not (equal x 1)) (not (equal x 0))) 
    (+ (fib (- x 1)) (fib (- x 2))) 1))

Try not to be too intimidated by the complexity or sheer or power of it.

August 11, 2006 @ 4:44 PM PDT
Cateogory: Programming
Tags: Lisp

3 Comments

roshan
Quoth roshan on August 13, 2006 @ 4:11 PM PDT
(defun fib (x)
  (if (and (not (equal x 1))
           (not (equal x 0)))
      (+ (fib (- x 1))
         (fib (- x 2))) 
    1))
roshan
Quoth roshan on August 13, 2006 @ 4:12 PM PDT

Ahh ... that was supposed to be properly formatted. :) Sorry ..

Brian
Quoth Brian on August 13, 2006 @ 4:36 PM PDT

Sorry. I wrapped it in pre tags for you. I must admit, properly formatting Lisp seems confusing. There was a half chapter on how to indent things, in Practical Common Lisp. Everything in Lisp seems entirely different from every other language I've ever studied, right down to formatting.