Hi John , Mike ...
Yes , they are isomorphic but they do not share the same memory location (pointer), so they do not "eq"
(setq a '(something))
(setq b a)
(eq a b) -> T (these share the same memory location) : you have to use equal for isomorphic compare. (and = for numbers).
Mr Lutz Mueller from NewLisp was able to condensate this potpourri in one single = (but I think you need lexical scoping then - while CL is dynamical )
https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node74.htmlThis comes with an even more severe warning about Lisp (espec. when coming from C, Pascal etc ... ) have a look
(setq a '(1 2 3 4))
(setq b a)
a -> (1 2 3 4)
b -> (1 2 3 4)
(incf (elt a 0)) -increment the value of the first element in the list a
a -> (2 2 3 4)
b -> (2 2 3 4)
yep, try it
(this because they point at a same object - always try to think in pointers when working in Lisp )
The iceberg and other stories :
---------------------------------------
The mechanism behind the code was correct , but parallel assignment seemingly not
this is the correct syntax in NewLisp
LispCode =
"(define (fib n) (if (and (number? n) (> n 2))
(let ((L '(0L 1L)))
(dotimes (i n)
(setq L (list (L 1) (+ (L 0) (L 1))))) (L 0) )
'I-can-not-do-such-a-thing.) )"
A quick example in tB attached : try Fib(100.000) it will be there in less than a sec
--- even interpreted ----
best Rob
(oops , yes remark the difference between (dotimes ...) between NewLisp and CL
CL (dotimes (i x return-value) .... )
NL (dotimes (i x [ exceptional-end-condition ] ..... )
My Fib starts with 1,1,2 (and indexbase 1) -- there may be people starting their sequence with 0,1 or even 1,2 -- the nth value may be different
.