extending nested lists

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

extending nested lists

Post by newdep »

Hello Lutz,

How difficult is it to extend the current depth of 16 to 256/512 for nested lists?
(..besides the difficulty, it probbaly would be a speed impact...)

Just currious..

regards, Norman.
-- (define? (Cornflakes))

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

Post by Lutz »

There is no limit in nesting anymore for lists. The limit of 16 which existed for some functions in 9.0 is gone. Most of the index stuff was reworked in 9.0.11. Whatever you memory gives can be done:

nesting of lists can be as deep as you want:

Code: Select all

> (set 'L '((((((((((((((((((((((((((((((((((((x)))))))))))))))))))))))))))))))))))))
((((((((((((((((((((((((((((((((((((x))))))))))))))))))))))))))))))))))))
> (set 'V (ref 'x L))
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
 0 0 0 0)
> (L V)
x
> (nth (L V))
x
> (nth-set (L V) 99)
x
> L
((((((((((((((((((((((((((((((((((((99))))))))))))))))))))))))))))))))))))
> (nth 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 L)
99
> (pop L V)
99
> L
(((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))
> 
Lutz

ps: newLISP is the only LISP with this kind of support for indexed lists, other LISPS have to write complex recursive algorithms to achieve this.
Last edited by Lutz on Fri Feb 09, 2007 1:59 pm, edited 1 time in total.

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

Post by newdep »

HA! Fantastic ! ;-)
-- (define? (Cornflakes))

Locked