previous | index | next

Lists and Scheme Pairs

We can implement lists using Scheme pairs:
(cons element list)
returns the list whose head is element and whose tail is list

(car list)
returns the head of list if list is nonempty

(cdr list)
returns the tail of list if list is nonempty

(null? list)
returns #T if list is empty, #F otherwise

Q: Why not use names with better abstraction, e.g. make-list, head, tail, and empty-list??

A: Because of established Scheme/Lisp programming tradition.


previous | index | next