I realized that the code for the fibonacci functions in the codepatterns

section is wrong: http://www.newlisp.org/CodePatterns.html#toc-5

The code is:

Code: Select all

```
; classic recursion
; slow and resource hungry
(define (fib n)
(if (< n 2) 1
(+ (fib (- n 1))
(fib (- n 2)))))
> (fib 12)
233
```

Code: Select all

```
; classic recursion
; slow and resource hungry
(define (fib n)
(if (< n 2) n
(+ (fib (- n 1))
(fib (- n 2)))))
> (fib 12)
144
```

that should be correct:

Code: Select all

```
; iteration
; fast and also returns the whole list
(define (fibo n , f)
(set 'f '(1 0))
(case n
(0 (1 f))
(1 f)
(true
(dotimes (i (- n 1))
(push (+ (f 0) (f 1)) f)))))
> (fibo 12)
(144 89 55 34 21 13 8 5 3 2 1 1 0)
```