question on Design Elements and Patterns in newLISP

Started by frontera000, June 11, 2006, 01:05:58 PM

Previous topic - Next topic

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?

William James

#1
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
 (nth-set (db i) value))
to
 (nth-set i db value))
and
 (change data 3 999)
to
 (change data:data 3 999)

HPW

#2
Quote
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.
Hans-Peter

cormullion

#3
Perhaps this is the change introduced in 8.8.1, so still in the Development release and release notes...


Quote 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...

Lutz

#4
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