eval and lists

For the Compleat Fan
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

eval and lists

Post by newdep »

Hello all,

How to put an evaluation inside a list, i lost track ;-)
example, the evaluated 'x must be appened to y.

(set 'y '())
(set 'x 1)
(append y (list (eval x))) <-- pitty for me..does not work...

any hint?

Norman.

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

Post by Lutz »

there are two ways to do this:

(set 'y '()) ;; not strictly necessary
(set 'x 1)


(push x y) => 1 ;; changes y returns x
y => (1)


(cons x y) => (1) ;; returns the new list leaves y unchanged
y => ()

Lutz

ps: note that you also can push on an y which has not a list already, in that case the old contents simply gets replaced by a list with the new element

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

Post by newdep »

Hello Lutz,

Thanks, actualy i knew that but im always turning the push variables around.. :-)

But this bring me to the function i needed it for, I was building a function called (pipe-sessions) but I think its better to control this from within the
newlisp core then from a function inside lisp. I dont have direct access to
the pipe IO so it'll be difficult to handle pipes as a function.

Anyway i was seeking for a function called (pipe-sessions) that would display/updated all opened pipes. If you think its usefull it would be a nice to have function, eventualy pipes are sockets so i assume the net-.... will
work on the pipes too?

Norman.

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

Post by Lutz »

There is a 'pipe' function in newLISP, you could use this to create your pipes and it returns the 2 handles in a list, you could make a list of those and handle it from there.

net-seesions only registers handles opened via socket calls.

Lutz

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

Post by newdep »

Hello Lutz,

yes that was what i was building ;-)

Norman.

Locked