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.

- 75 -def AND X Y =if and (isbool X) (isbool Y)then MAKE_BOOL (and (value X) (value Y))else BOOL_ERRORWe will now consider how these definitions bolt <strong>to</strong>gether by looking at:AND TRUE FALSEAfter definition replacement and initial bound variable substitution we have:First of all:if and (isbool TRUE) (isbool FALSE)then MAKE_BOOL (and (value TRUE) (value FALSE))else BOOL_ERRORisbool TRUE ==λobj.(equal (type obj) bool_type) TRUE =>equal (type TRUE) bool_type ==equal (λobj.(obj select_first) TRUE) bool_type ->equal (TRUE select_first) bool_type ==equal (λs.(s bool_type true) select_first) bool_type -> ... ->equal bool_type bool_type => ... =>trueSimilarly:Thus:isbool FALSE => ... =>trueand (isbool TRUE) (isbool FALSE) -> ... ->and true (isbool FALSE) -> ... ->and true true => ... =>trueWe now evaluate:MAKE_BOOL (and (value TRUE) (value FALSE))For the and:value TRUE ==λobj.(obj select_second) TRUE =>

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

Saved successfully!

Ooh no, something went wrong!