The "nth" seems like the simpler route to take. I checked out that link you gave Lee Mac. That's alot of variations. If I went the car cdr route, the 4th element would be cadddr, correct?
Not a problem AWW, I use c--r up to the 3rd or 4th level, but then nth becomes easier to read (but then it depends on the situation, nth is handy when you want to use a variable as the index argument).
The way to look at it with the
c---r functions is that a "
d" will "
knock an element off the front", and an "
a" will "
retrieve the first element"
As an Example:
(setq lst '[color=red]([/color]0 1 2 [color=blue]([/color]3 [color=green]([/color]4 5 6[color=green])[/color] 7 8 9[color=blue])[/color][color=red])[/color])
(c[color=blue]ad[/color]r lst) = 1 ['[color=red]d[/color]' takes away the [color=red]0[/color], '[color=red]a[/color]' looks as the [color=red]1[/color]]
(c[color=blue]ddd[/color]r lst) = ((3 (4 5 6) 7 8 9)) [three '[color=red]d[/color]'s so knock off the first [color=red]3[/color] elements - [color=red]Note that its still nested[/color] ]
(c[color=blue]a[/color]r (c[color=blue]ddd[/color]r lst)) = (c[color=blue]addd[/color]r lst) = (c[color=blue]a[/color]r '((3 (4 5 6) 7 8 9))) = (3 (4 5 6) 7 8 9)
(c[color=blue]a[/color]r (c[color=blue]ada[/color]r (c[color=blue]ddd[/color]r lst))) = (c[color=blue]aa[/color]dr (c[color=blue]addd[/color]r lst)) = 4
Just bear in mind that although the example with
cdddr takes away the first
three elements of the list, the returned list is
still nested, as there is no '
a' to look at the first element of the nested list with the three taken away.
Hope this all makes sense.
Lee