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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

- 48 -def = We can now re-write all our definitions:def identity x = xdef self_apply s = s sdef apply func = λarg.(func arg)and hence:def apply func arg = func argdef select_first first = λsecond.firstand hence:def select_first first second = firstdef select_second first = λsecond.secondand hence:def select_second first second = seconddef make_pair e1 = λe2.λc.(c e1 e2)and hence:and hence:def make_pair e1 e2 = λc.(c e1 e2)def make_pair e1 e2 c = c e1 e2def cond e1 e2 c = c e1 e2def true first second = firstdef false first second = seconddef not x = x false truedef and x y = x y falsedef or x y = x true yFor some functions there are standard equivalent notations. Thus, it is usual <strong>to</strong> write:cond in an if ... then ... else ... form. We will use:if then else

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

Saved successfully!

Ooh no, something went wrong!