An Introduction to Functional Programming Through Lambda Calculus (Dover Books on Mathematics)

An Introduction to Functional Programming Through Lambda Calculus (Dover Books on Mathematics)

Greg Michaelson

Language: English

Pages: 336

ISBN: 0486478831

Format: PDF / Kindle (mobi) / ePub


Functional programming is rooted in lambda calculus, which constitutes the world's smallest programming language. This well-respected text offers an accessible introduction to functional programming concepts and techniques for students of mathematics and computer science. The treatment is as nontechnical as possible, and it assumes no prior knowledge of mathematics or functional programming. Cogent examples illuminate the central ideas, and numerous exercises appear throughout the text, offering reinforcement of key concepts. All problems feature complete solutions.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

examples and so it is important that you work through the material slowly and consistently. 2.4 λ expressions The λ calculus is a system for manipulating λ expressions. A λ expression may be a name to identify an abstraction point, a function to introduce an abstraction or a function application to specialize an abstraction: A name may be any sequence of non-blank characters, for example: A λ function is an abstraction over a λ expression and has the form: where: for example:

should replace the first f in: but not the f in the body of: This is a new function with a new bound variable which just happens to have the same name as a previous bound variable. To clarify this we need to be more specific about how bound variables relate to variables in function bodies. For an arbitrary function: the bound variable may correspond to occurrences of in is . For example, in:

body then correspond to the new bound variable and not the old. In formal terms, all the free occurrences of in introduced by the original function. is in scope in

In the above example: Replacement will never terminate! We want the replacement to take place a finite number of times, depending on particular uses of the function with particular arguments but, of course, there is no way of knowing what argument values are required when the function is defined. If we did know, then we could construct specific functions for specific cases, rather than a general purpose function. This was not a problem in earlier examples, because we knew replacement would

a single character string to the equivalent ASCII code value: For example: Similarly, the standard function: converts an integer ASCII value into the equivalent single character string: For example: In order to access the individual characters making up a string, it must be unpacked into a list of single character strings. The standard function: does this: For example: Similarly, the standard function: converts a list of strings to a single string: For example:

Download sample

Download