int |
Integer numbers
|
30- (62-) bits; also 32 and 64 bits. 1, 2, -3567, 1_073_741_823
|
float |
Floating-point numbers
|
IEEE-754, 53-bit. 1.34713723849427667e+177, 1. = 1e0 = 1.0e0
|
char |
Characters
|
ISO-8859-1. 'a', '\n'
|
string |
Character strings
|
Max 224-6 or 16,777,211 characters. Mutable.
(257-9). "", "foo",
"tabbed\tdata\twith\ttrailing\tnewline\n", "foo".[0] = 'f'
|
bool |
Booleans
|
true, false
|
unit |
Unit value
|
()
|
tuples |
Pairs, triples, etc
|
true, 45, "yikes"
|
list |
Lists
|
Homogenous. Lisp-like. O(1) cons, O(n) length. [],
["foo";"bar";"baz"], [1;2;3;4;5]
|
array |
Arrays (vectors)
|
Homogenous. Perl-, Tcl-like. O(1) access to elements,
O(1) "length". [||], [|1;2;3|], [|1;2;3|].(0) = 1
|
exn |
Exceptions
|
exception Foo |
format |
printf formats
|
sprintf "Hello, %s!" |
functions |
Functions
|
fun n m -> n + m
|
option |
Optional values
|
None, Some 12, Some "foo"
|
records |
Records (structs)
|
{foo = 1; bar = "yikes"}
|
ref |
References
|
ref 1, ref true |
variants |
User-defined types
|
type intlist = Nil | Cons of int * intlist |
polymorphic variants |
Mysterious!
|
objects |
Instances of classes
|
object
val mutable x = 0
method get_x = x
method move d = x <- x + d
end
|