Nm... After tinkering in the debugger.. using 'pp etc..
I get it. I am still getting the (= code data) in picolisp.

## Advertising

This gives the results I wanted.
(de Fibonacci (N)
(let (Fib '(1 1 0) R 0)
(do N
(rot Fib)
(set Fib (+ (cadr Fib) (caddr Fib)))
)
(setq R (car Fib))
(set Fib 1 (cdr Fib) 1 (cddr Fib) 0)
R
) )
Now I can write...
: (Fibonacci 1)
-> 2
: (Fibonacci 10)
-> 144
: (bench (nil (Fibonacci 100000)))
3.388 sec
: (length (chop (Fibonacci 100000)))
-> 20899 digits!
Picolisp bignums are awesome!
/Lindsay
On Sat, Mar 11, 2017 at 10:49 AM, Lindsay John Lawrence <
lawrence.lindsayj...@gmail.com> wrote:
> Hi
>
> I am having difficulty understanding the following..
>
> This works as expected...
>
> : (setq Sum '(1 1 0))
> -> (1 1 0)
> : (set Sum (+ (cadr Sum) (caddr Sum)))
> -> 1
> : (rot Sum)
> -> (0 1 1)
> : (set Sum (+ (cadr Sum) (caddr Sum)))
> -> 2
> : (rot Sum)
> -> (1 2 1)
> : (set Sum (+ (cadr Sum) (caddr Sum)))
> -> 3
> : (rot Sum)
> -> (1 3 2)
> : (set Sum (+ (cadr Sum) (caddr Sum)))
> -> 5
> : (rot Sum)
> -> (2 5 3)
> : (set Sum (+ (cadr Sum) (caddr Sum)))
> -> 8
> : Sum
> -> (8 5 3)
>
> However, when I put it in a function...
>
> (de Fibonacci (N)
> (let (Fib '(1 1 0))
> (do N
> (rot Fib)
> (set Fib (+ (cadr Fib) (caddr Fib))) )
> (car Fib) ) )
>
> The results are something like a 'co routine or 'job... in that Fib as a
> memory between calls and it is not re-initialized with the 'let as I
> expected.
>
> -> Fibonacci
> : (Fibonacci 1)
> -> 2
> : (Fibonacci 1)
> -> 3
> : (Fibonacci 1)
> -> 5
> : (Fibonacci 1)
> -> 8
> ...
>
> The behavior I expected was
>
> : (Fibonacci 3)
> -> 5
> ..
>
> Why?
>
> /Lindsay
>
>
>
>
>