[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

simple and useful demonstrative case

(defun fib (n)
       (do ((old 0 new)
	    (new 1 (+ old new))
	    (i 0 (1+ i)))
	   ((= i n) old)))

This is our friend the fibonacci numbers. I want to demonstrate
it to people and compile it for my own use. I know it uses
fixnums, but that's ok.

Run it interpretted:
   (setq base (setq ibase 10.))
   (fib 20)
   6765.				; the AI phone number
demonstrate the compiler: (compiled function loaded of course)
   (fib 20)
   524288.				; phone number??

A naive user would be totally lost at such a response from such a
simple (and useful) function.