10.07.2015 Views

An Introduction to Functional Programming Through Lambda Calculus

An Introduction to Functional Programming Through Lambda Calculus

An Introduction to Functional Programming Through Lambda Calculus

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

- 91 -If the head of a list and the heads of all of its tail lists are not lists then the list is said <strong>to</strong> be linear. In LISP parlance,an object in a list which is not a list (or a function) is known as an a<strong>to</strong>m.The head and tail may be selected from non-empty lists:HEAD (CONS H T) = HTAIL (CONS H T) = Tbut head and tail selection from an empty list is not permitted:HEAD NIL = LIST_ERRORTAIL NIL = LIST_ERRORConsider, for example, the linear list of numbers we constructed above:CONS 1 (CONS 2 (CONS 3 NIL))The head of this list:is:HEAD (CONS 1 (CONS 2 (CONS 3 NIL)))1The tail of this list:is:TAIL (CONS 1 (CONS 2 (CONS 3 NIL)))CONS 2 (CONS 3 NIL)The head of the tail of the list:is:which is:HEAD (TAIL (CONS 1 (CONS 2 (CONS 3 NIL))))HEAD (CONS 2 (CONS 3 NIL))2The tail of the tail of the list:is:which is:TAIL (TAIL (CONS 1 (CONS 2 (CONS 3 NIL))))TAIL (CONS 2 (CONS 3 NIL))CONS 3 NIL

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!