first,second,third,forth,fifth,sixth, ..., rest


Synopsis

(first <lst>)

(second <lst>)

(third <lst>)

(fourth <lst>)

(fifth <lst>)

(sixth <lst>) #- SMALL

(seventh <lst>) #- SMALL

(eighth <lst>) #- SMALL

(ninth <lst>) #- SMALL

(tenth <lst>) #- SMALL

(rest <lst>)

Description

Better as NTH, CAR or CDR.

They return the first second and so on, elements of list. Same as (CAR lst), (CADR lst), ...

REST returns the rest after the first element of the list, same as (CDR lst).

They should be used instead of CAR, CADR, ... for lists to improve the readability of the code.

Secondly they will not fail on too short lists which is useful for accessing lists as structures and keeping structures short, using optional slots which default to nil.

But for points better use: X-OF, Y-OF and Z-OF.

Difference to NTH

In short: To get the fourth element of a list better use (FOURTH lst) then (NTH 3 lst)

They accept nil as argument too, which is better than NTH.

(NTH 3 lst) looks like (FOURTH lst), but is NOT the same, because (NTH 3 nil) will throw an error, but (FOURTH nil) will return nil.

Arguments

list: any list, including not proper lists

Return Value

The specified element(s) of the list or nil.

Side Effects

None.

Module

(std-require 'STDLIST)

Defined in STDLIST

Parts are #- SMALL