The ML interpreter has a very clear, simple operation. The process of
interpretation is just that of reduction. An expression is entered at the
prompt and is reduced according to a simple set of rules.
Example: Evaluate times4(5)
times4 x=double(double x) for any value of x. Specifically we let x be 5 here.
|=double(2*5)||we replace the sub expression double 5 with 2*5 as the equation for double permits.|
|=double(10)||We simply replace 2*5 with 10.|
|=2*10||Use the equation for double again.|
The functions ord and chr convert characters to ASCII values and vice versa. size returns the number of characters in the string and substring accepts a string, the start position and length of the substring, note that the first character of the string is number zero. Suppose we wish to create the function clip which removes the last character from its input.