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.

- 30 -In general, applying make_pair <strong>to</strong> arbitrary arguments:andgives:((make_pair ) ) ==((λfirst.λsecond.λfunc.((func first) second)) ) ) =>(λsecond.λfunc.((func ) second) ) =>λfunc.((func ) )Thereafter, applying this function <strong>to</strong> select_first returns the first argument:(λfunc.((func ) ) select_first) =>((select_first ) ) ==((λfirst.λ second.first ) ) =>(λsecond. ) =>and applying this function <strong>to</strong> select_second returns the second argument:(λfunc.((func ) ) select_second) =>((select_second ) ) ==((λfirst.λ second.second ) ) =>(λsecond.second ) =>2.13. Free and bound variablesWe are now going <strong>to</strong> consider how we ensure that arguments are substituted correctly for bound variables in functionbodies. If all the bound variables for functions in an expression have distinct names then there is no problem.For example, in:(λf.(f λx.x) λs.(s s))there are three functions. The first has bound variable f, the second has bound variable x and the third has boundvariable s. Thus:(λf.(f λx.x) λs.(s s)) =>(λs.(s s) λx.x) =>

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

Saved successfully!

Ooh no, something went wrong!