newLISP Fan Club

Forum => Anything else we might add? => Topic started by: frontera000 on June 11, 2006, 01:05:58 PM

Title: question on Design Elements and Patterns in newLISP
Post by: frontera000 on June 11, 2006, 01:05:58 PM
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?
Title:
Post by: William James on June 11, 2006, 05:19:35 PM
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)
Title:
Post by: HPW on June 11, 2006, 11:08:04 PM
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.
Title:
Post by: cormullion on June 12, 2006, 12:24:28 AM
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...
Title:
Post by: Lutz on June 12, 2006, 07:34:08 AM
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