Alexander Burger writes:
Hi Alex,
>> In PicoLisp, the cdr of a circular list always seems to point to the
>> beginning of the list.
>
> Yes, as far as the directy reader/printer syntax is concerned. But you
> can easily specify a list where the last cell points to some other
> cell.
>
> For example, in this list of 6 cells the last 3 cells form a circular
> list:
>
>: (1 2 3 . (4 5 6 .))
>-> (1 2 3 . (4 5 6 .))
>: (more @)
>1
>2
>3
>4
>5
>6
>4
>5
>6
>4
>...
>
> Personally, I find syntax much simpler and cleaner than using labels.
I see, and indeed it looks clean and nice.
> What cannot be directly expressed, however, is a pointer into a sublist
> of the current list (or even into arbitrary other lists).
>
> Here you have to resort to "labels", by setting a variable to the
> (sub)list in question:
>
>: (1 2 (3 4 . `(setq "n1" (5 6))) 7 . `"n1")
>-> (1 2 (3 4 5 6) 7 5 6)
>
>: (1 2 3 ~(setq "n2" (4 5 6)))
>-> (1 2 3 4 5 6)
>: (7 8 ~"n2")
>-> (7 8 4 5 6)
Does not look as clean and nice as before, but what counts - it can be
done, great.
Thanks again, I'm glad I asked, it would have taken me forever to
(probably not) figure this out.
--
cheers,
Thorsten
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe