eval and lists

Started by newdep, March 04, 2004, 01:30:11 PM

Previous topic - Next topic

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.
-- (define? (Cornflakes))

Lutz

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

#2
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.
-- (define? (Cornflakes))

Lutz

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

#4
Hello Lutz,



yes that was what i was building ;-)



Norman.
-- (define? (Cornflakes))