Functions on Int and Real | ||
name | type(s) | action |
~ | int -> int or real -> real | negates its argument |
min, max | int*int -> int | obvious |
abs | int -> int or real -> real | absolute value |
real | int -> real | convert integer into real of same value |
floor, ceiling, trunc | real -> int | conversions |
sin, cos, arctan | real -> real | angles in radians |
sqrt,exp,ln | real -> real | obvious |
chr | int -> string | ASCII code |
makestring | int -> string or real -> string | produces text digits |
int -> unit or real -> unit | side effect is output |
Functions on String | ||
name | type(s) | action |
explode | string -> string list | makes list of single characters |
implode | string list -> string | ... |
size | string -> int | ... |
substring | string*int*int -> string | first int is starting position (from 0), second int is # if characters to include; will generate exception is # characters runs off end of string |
ord | string -> int | convert first character of string to ASCII code |
ordof | string*int -> int | convert character at position in a string |
string -> unit | overloaded... |
Functions on Boolean | ||
name | type(s) | action |
andalso, orelse | bool*bool -> bool | logical operations |
not | bool -> bool | logical negation |
makestring | bool -> string | turn boolean value into its name |
bool -> unit | overloaded ... |
Functions on Lists | ||
name | type(s) | action |
hd | 'a list -> 'a | head of a list |
tl | 'a list -> 'a list | tail of a list |
nth | 'a list * int -> 'a | list element selector (start from 0) |
nthtail | 'a list * int -> 'a list | produce tail of a list starting from the indicated element |
null | 'a list -> bool | is the list empty? |
length | 'a list -> int | number of elements in a list |
rev | 'a list -> 'a list | reverse a list |
map | ('a -> 'b) -> 'a list -> 'b list | apply a function to all elements in a list |
app, revapp | ('a -> 'b) -> 'a list -> unit | like map but return "unit" instead of the list... however, the function is applied to elements in the list; useful for side effects like printing each list element |
fold,revfold | (('a * 'b) -> 'b) -> 'a list -> 'b -> 'b | composes a list of functions |
exists | ('a -> bool) -> 'a list -> bool | takes a predicate P and a list of type-matching elements, returns true if at least one of the list elements satisfies P. |
name | description |
Io | an error has occurred during input or output |
Bind | a pattern has failed to match the expression to which it must be bound
ex: val x::xs = nil |
Match | a match has no pattern that matches the expression to which it is applied |
Div | a division by zero |
Overflow | The result of arithmetic op on int or real does not fit storage for that type |
Sqrt | arg to sqrt is negative |
Exp | arg to exp is invalid |
Ln | arg to ln is invalid |
Chr | chr was given an integer out of range |
Ord | ord was given the empty string |
Substring | substring was given a range not fully in the string argument
ex: substring("abc",2,4) |
Range | raised with type "bytearray" |
Hd, Tl | using hd or tl on empty list |
Nth, NthTail | functions applied to list without the desired position in it
ex: nth([10,20,30],5) |
Subscript | array reference out of range |