On 4/10/2012 4:10 PM, Rainer Weikusat wrote:
'car' and 'cdr' refer to cons cells in Lisp, not to strings. How the first/rest terminology can be sensibly applied to 'C strings' (which are similar to linked-lists in the sense that there's a 'special termination value' instead of an explicit length) was already explained elsewhere.
The idea of partitioning a collection into one item and the rest can be applied to any collection (or subcollection). Python iterators embody this generic idea. An iterator represents a collection (or subcollection). Built-in next(iter) either returns an item while updating iter to represent the subcollection without the item, or raises StopIteration. *How* to test emptiness, 'remove' an item, and mutate the iterator are all implementation details hidden inside the iterator. They are mostly irrelevant to the abstract operation of repeated partitioning to process each item of a collection.
-- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list