Page 1 of 1

rotate on list

Posted: Fri Feb 27, 2004 7:58 pm
by newdep
Hello Lutz,

(Linux 7.5.4)

Im currious what im doing wrong in the following example, perhpas you can
point out the mistake. I could emagin that (net-sessions) is static in itself still the first rotate Is accepted.

>(net-sessions)
(4 3)
>(rotate (net-sessions))
(3 4)
>(rotate (net-sessions))
(3 4)

As you can see the 'rotate only worked once, still rotate is destructive to the
'net-sessions list, its not updated a second time. If you would say that i should isolate the list from 'net-sessions befor doing a rotate (because of the dynamic/static behaviour of the 'net-sessions list) i'll work with that ;-)

Ofcourse a normal list works...

> (set 'x (list 1 2 3 4))
(1 2 3 4)
> (rotate x)
(4 1 2 3)
> (rotate x)
(3 4 1 2)
> (rotate x)
(2 3 4 1)
> (rotate x)
(1 2 3 4)


Regards,
Norman.

Posted: Fri Feb 27, 2004 8:48 pm
by eddier
net-sessions is always creating the new list: (4 3)

No matter how many times you call net-sessions, it will create a new list: (4 3)

If you save the list in a variable say

(setq sessions (net-sessions))

and rotate on the variable sessions your ok.

Eddie

Posted: Fri Feb 27, 2004 8:54 pm
by newdep
Hello Eddie, Mmmm your right... i think i mixed up the console output and the
variable i was playing with ;-) lets close this chapter quicky ;-)
Norman.

Posted: Fri Feb 27, 2004 8:56 pm
by Lutz
correct, 'net-sessions' is not static but reports the currently open listening or connection sockets. Each time 'net-sessions' is called it constructs the new list of currently active sockets.

Lutz