pop and find

Q&A's, tips, howto's
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

pop and find

Post by newdep »

Hi Lutz,

I could be wrong that pop and find worked together previously...?
seems they don't, or was this realy always the case?

(set 'a '( "ab"))
(pop a (find "de" a))

ERR: missing argument

..that because 'find returned 'nil

PS: missing argument is somewhat strange here.. as 'nil is an argument
but not an index.
-- (define? (Cornflakes))

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Actualy i have the same with =>

> (set 'a '( "a" "b" "c" "a"))
("a" "b" "c" "a")

>(pop a (ref "Z" a))

ERR: missing argument
>


I dont understand this, according to the manual list-indexes should
be possible together with 'ref.. Now i always need to check if 'ref isnt 'nil
and cant nest them anymore..

I know the ERR: was introduced someway back...
but Im a true? empty? nil? checking programmer..
(Time to assimilate with the consortium :-)


PS: Would be nice to have a summery in the manual that
displays in an Eye blink What functions return 'nil , '() or ERR: on errors..
-- (define? (Cornflakes))

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

You cannot use an empty list () as an index, there has to be at least one number in it. Nothing has changed here, it always gave an error.

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

oke...good ;-) I though it was the Sun that hit me ;-)


I find myself more and more using (and ) & (or ) inside
newlisp, I almost dont use any begin, unless, if, when, anymore..

Is that a good thing or a bad thing? basicly it all comes back to 0 or 1..

But programming in the (and ) & (or ) mode is pretty specific and needs
to be secured..but the code looks very very very clean and readable! ;-)
-- (define? (Cornflakes))

Locked