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.

- 92 -The head of the tail of the tail of this list:HEAD (TAIL (TAIL (CONS 1 (CONS 2 (CONS 3 NIL)))))is:HEAD (TAIL (CONS 2 (CONS 3 NIL)))which is:HEAD (CONS 3 NIL)giving:3The tail of the tail of the tail of the list:TAIL (TAIL (TAIL (CONS 1 (CONS 2 (CONS 3 NIL)))))is:TAIL (TAIL (CONS 2 (CONS 3 NIL)))which is:TAIL (CONS 3 NIL)giving:NIL6.3. List representationFirst we define the list type:def list_type = threeand associated tests:def islist = istype list_typedef ISLIST L = MAKE_BOOL (islist L)and error object:def LIST_ERROR = MAKE_ERROR list_typeA list value will consist of a pair made from the list head and tail so the general form of a list object with head and tail will be:λs.(s listtypeλs.(s ))Thus, we define:

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

Saved successfully!

Ooh no, something went wrong!