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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

- 25 -We can use the self application function <strong>to</strong> build versions of other functions. For example, let us define a functionwith the same effect as the identity function:def identity2 = λx.((apply identity) x)Let us apply this <strong>to</strong> the identity function:(identity2 identity) ==(λx.((apply identity) x) identity) =>((apply identity) identity) ==((λfunc.λarg.(func arg) identity) identity) =>(λarg.(identity arg) identity) =>(identity identity) => ... =>identityLet us show that identity and identity2 are equivalent. Suppose:stands for any expression. Then:(identity2 ) ==(λx.((apply identity) x) ) =>((apply identity) ) => ... =>(identity ) => ... =>so identity and identity2 have the same effect.We can use the function application function <strong>to</strong> define a function with the same effect as the function applicationfunction itself. Suppose:is any function. Then:(apply ) ==(λf.λa.(f a) ) =>λa.( a)Applying this <strong>to</strong> any argument:we get:

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

Saved successfully!

Ooh no, something went wrong!