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.

- 165 -<strong>to</strong> indicate both integer and real so these opera<strong>to</strong>rs types might be:fn : (num * num) -> numas they take two numeric arguments, with infix syntax for a tuple, and return a numeric result.Note that for each opera<strong>to</strong>r both arguments must be the same type.The infix opera<strong>to</strong>r:divis for integer division. We can use op <strong>to</strong> convert it <strong>to</strong> prefix form <strong>to</strong> display its type:- op div;> fn : (int * int) -> intArithmetic expressions are built from these opera<strong>to</strong>rs with the brackets ( and ), for example:- 6 * 7 div (7 - 4) + 28;> 42 : intNote that there is no strict bracketing. The usual precedence:before:before:applies.( )div *+ -The numeric negation opera<strong>to</strong>r is:˜again with effective type:fn : num -> numas it is overloaded for use with integers and reals.9.9. String standard functionsThe binary infix opera<strong>to</strong>r:ˆconcatenates two strings <strong>to</strong>gether:- op ˆ;> fn : (string * string) -> string

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

Saved successfully!

Ooh no, something went wrong!