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.

- 66 -Applicative order reduction notation-> - applicative order β reduction-> ... -> - multiple applicative order β reductionRecursion functiondef recursive f = λs.(f (s s)) λs.(f (s s))For:def = ... ( ... ) ...write:def f = ... (f ... ) ...def = recursive Note that:recursive => ... => (recursive )Recursion notationrec = ==def = recursive λf.4.10. Exercises1) The following function finds the sum of the numbers between n and zero:def sum1 f n =if iszero nthen zeroelse add n (f (pred n))def sum = recursive sum1Evaluate:sum three2) Write a function that finds the product of the numbers between n and one:def prod1 f n = ...def prod = recursive prod1 (*)so that:prod nin lambda calculus is equivalent <strong>to</strong>:

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

Saved successfully!

Ooh no, something went wrong!