Hi Lindsay,
> (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.
This is because 'rot' is a destructive operation. The list (1 1 0), i.e. these
three *cells*, are a constant in the body of the function (please 'F' -> 'f' ;)
You can see this if you do (pp 'fibonacci) after you executed it.
As in all such cases of destructive operations, the right way is to use a fresh
(newly built) list:
(de fibonacci (N)
(let Fib (list 1 1 0) # builds a new list
(do N
...
♪♫ Alex
--
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe