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.

- 168 -In order <strong>to</strong> access the individual characters making up a string it must be unpacked in<strong>to</strong> a list of single characterstrings. The standard function:does this:explode- explode;> fn : string -> (string list)For example:- explode "hello";> ["h","e","l","l",’o"] : string listSimilarly, the standard function:implodeconverts a list of strings <strong>to</strong> a single string:- implode;> fn : (string list) -> stringFor example:- implode ["Time ","for ","tea?"];> "Time for tea?" : stringNote that implode will join strings of any length.9.12. Comparison opera<strong>to</strong>rsSML provides a variety of overloaded infix comparison opera<strong>to</strong>rs. Equality and inequality are tested with:= and may be used with booleans, integers, strings, lists and tuples.The less than, less than or equal, greater than and greater than or equal opera<strong>to</strong>rs:< = >may be used with numbers and strings. For strings, they test for alphabetic order, for example:- "haggis" < "oatcake";> true : boolSML systems may not display these opera<strong>to</strong>rs’ types because they are overloaded.For all these opera<strong>to</strong>rs, both arguments must be of the same type.9.13. Functions

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

Saved successfully!

Ooh no, something went wrong!