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 @ 11:44 PM PDT
Cateogory: Programming
Tags: Lisp

3 Comments

roshan
Quoth roshan on August 13, 2006 @ 11: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 @ 11:12 PM PDT

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

Brian
Quoth Brian on August 13, 2006 @ 11: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.

Speak your Mind

You can use Markdown in your comment.
Email/URL are optional. Email is only used for Gravatar.

Preview