Page 1 of 1
question on Design Elements and Patterns in newLISP
Posted: Sun Jun 11, 2006 8:05 pm
by frontera000
i am new to newlisp.
section 6 of Design Elements and Patterns in newLISP
has the following:
(set 'data:data '(a b c d e f g h))
(define (change db i value)
(nth-set (db i) value))
(change data 3 999)
but db is undefined when change is called.
ERR:value expected in function nth-set : (db i)
can anyone tell me why?
Posted: Mon Jun 12, 2006 12:19 am
by William James
It doesn't work for me either, but the book is for version 8.8.9 of newLISP and my version is 8.8.0. I presume that the code is correct for version 8.8.9.
I had to change
to
and
to
Posted: Mon Jun 12, 2006 6:08 am
by HPW
newLISP v.8.8.9 on Win32 MinGW.
> (set 'data:data '(a b c d e f g h))
(a b c d e f g h)
> (define (change db i value)(nth-set (db i) value))
(lambda (db i value) (nth-set (db i) value))
> (change data 3 999)
d
> data
data
> data:data
(a b c 999 e f g h)
>
Works for me.
Posted: Mon Jun 12, 2006 7:24 am
by cormullion
Perhaps this is the change introduced in 8.8.1, so still in the Development release and release notes...
implicit n-rest and slice on default lists and strings:
(set 'foo:foo '(a s d f g h j))
(2 foo) => (d f g h j)
(-3 2 foo) => (g h)
Or perhaps it isn't.
The Design Patterns document is way ahead of itself, it seems! Good for it, but confusing if that's one piece of the documentation that isn't tied to the release...
Posted: Mon Jun 12, 2006 2:34 pm
by Lutz
Sorry for the version confusion with the "Design Patterns" document, it says: "newLISP 8.8.9 and after" on the title page. I will add this also on the Documentations page so it does not get overlooked.
Lutz