How would these list operations be done in Arc? NewLisp has two ways to get the nth element of a list: > (set 'lst '(zero one two three four five six))
(zero one two three four five six)
> (nth (lst 5))
five
> (lst 5)
five
Is this the best way to do it in Arc? (car (nthcdr 5 lst))
To tack on to the end of the list: > (push 'seven lst -1)
seven
> lst
(zero one two three four five six seven)
The manual states:"Repeatedly using push to the end of a list using -1 as the int-index is optimized and as fast as pushing to the front of a list with no index at all. This can be used to efficiently grow a list." By default, push adds at the beginning of the list: > (push 'xxx lst)
xxx
> lst
(xxx zero one two three four five six seven)
To pop from the end of the list: > (pop lst -1)
seven
> lst
(xxx zero one two three four five six)
|