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.

- 58 -mult1 ==(λf.λx.λy.if iszero ythen zeroelse add x (f x (pred y))) =>λx.λy.if iszero ythen zeroelse add x ( x (pred y))In the body we have: x (pred y)but we require:so that:mult1 x (pred y)gets passed on again through mult1’s bound variable f <strong>to</strong> the next level of recursion. Thus, the copy mechanismmust be such that: => ... => mult1 In general, from function f passed <strong>to</strong> recursive, we need: => ... => f so the copy mechanism must be an application and that application must be self-replicating.We know that the self-application function:λs.(s s)will self-replicate when applied <strong>to</strong> itself but the replication never ends.Self-application may be delayed through abstraction with the construction of a new function:λf.λs.(f (s s))Here, the self-application:(s s)becomes an argument for f. This might, for example, be a function with a conditional expression in its body whichwill only lead <strong>to</strong> the evaluation of its argument when some condition is met.When this new function is applied <strong>to</strong> an arbitrary function, we getλf.λs.(f (s s)) =>λs.( (s s))

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

Saved successfully!

Ooh no, something went wrong!