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.

- 67 -n * n-1 * n-2 * ... * 1in normal arithmetic.Evaluate:prod three3) Write a function which finds the sum of applying a function fun <strong>to</strong> the numbers between n and zero:def fun_sum1 f fun n = ...def fun_sum = recursive fun_sum1For example, given the ‘squaring’ function:def sq x = mult x xthen:fun_sum sq threein the λ calculus is equivalent <strong>to</strong>:0 2 + 1 2 + 2 2 + 3 2in arithmetic.Evaluate:fun_sum double threegiven the ‘doubling’ function:def double x = add x x4) Define a function <strong>to</strong> find the sum of applying a function fun <strong>to</strong> the numbers between n and zero in steps ofs:def fun_sum_step1 f fun n s = ...def fun_sum_step = recursive fun_sum_step1so, for example:fun_sum_step sq six twoin the λ calculus is equivalent <strong>to</strong>:6 2 + 4 2 + 2 2 + 0 2in normal arithmetic.Evaluate:________________________________________________(*) There’s no escape from ‘fac<strong>to</strong>rial’...

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

Saved successfully!

Ooh no, something went wrong!