Hi Jon, > (length '(de *Day . (Mon Tue Wed Thu Fri Sat Sun .))) > .. > Why does 'length' have such problems here?
Circular lists are generally rather dangerous. PicLisp supports (kind of ;-) only what I would call "primary circular lists", i.e. lists that circulate back to the first cell (a b c .) but not e.g. (a b . (c d .)) which circulates back to the third cell. Though the system itself (for example the garbage collector) can handle arbitrary circular lists internally, reading, printing or mapping may cause problems. It is up to the application to be prepared for possible circularities, and act appropriately. The reason is that it would impose enormous overhead to keep track of all visited cells and in all circumstances to detect circularities. System functions like 'length', 'size', comparisons - but also some tools like 'who' - keep track of the first cell to detect primary circularities, but not more. I found, though, that this is surprisingly useful, and covers most practical cases. So your idea to use the return value of 'length' (i.e. 'T' for circular lists) is very good (at least in cases where the runtime of repeated length calculations does not hurt), but it cannot solve all problems. An improved solution could keep a list of cells during traversal, to detect at least a circularity up to a certain size. Cheers, Alex -- Software Lab. Alexander Burger Bahnhofstr. 24a, D-86462 Langweid [EMAIL PROTECTED], www.software-lab.de, +49 8230 5060