(last list)


Determine the last item in that list.


This function returns the last element in a list. The element is not returned in a list, unless the last element is a list, as shown by the examples below.

Examples

Code Returns
(setq b ' ( 1 2 3 4)) (1 2 3 4)
(last b) 4
(last '("first" "second" ("third" "fourth"))) ("third" "fourth")

NOTE This function should be used with caution. For example, you may want a function to retrieve the z-coordinate of a point. However, there are some cases in which the point contains only the x- and y-coordinates. Your function would accidentally get the y-coordinate. For this reason, it is sometimes a better idea to use a mixture of the car and cdr functions.

Tell me about...

(length list)

(nth integer list)

(reverse list)

(setq symbol1 statement1 [symbol2 statement2] ...)

LISP Compatibility

Programming Overview of LISP (LISt Processing) Language