nth_car, nth_cdr
nth_car, nth_cdr — iteratively apply the car and
cdr functions to a list.
nth_car (list, number)
nth_cdr (list, number)
listAny list.
numberThe number of cars (or cdrs) to apply to the list argument. Non-integers are rounded down. Non-numbers are treated as zero.
An element of the list, or nil.
The nth_car and nth_cdr
functions iteratively apply the car and
cdr functions to a list. If the list argument is
not a list, or if the result of any subsequent application of
car or cdr is not a list, the
result is nil. If the
number of applications is less than or equal to 0, the
result is the original list.
Gamma>c = list (list(list(list(4,5))));((((4 5))))Gamma>nth_car(c,2);((4 5))Gamma>nth_car(c,4);4Gamma>b = list (6,7,8,9,10);(6 7 8 9 10)Gamma>nth_cdr (b,2);(8 9 10)Gamma>nth_cdr(b,5);nilGamma>nth_cdr(b,4);(10)Gamma>