#SML/NJ cheatsheet ##Types and expression
- unit :
();
- boolean :
true;
false;
- int :
5;
~5;
5 + 5;
5 - 5;
5 * 5;
- real :
3.141592;
3141592e~6;
2.1 + 3.4;
2.11 - 1.223;
3213e~4 * 33.2;
23.1 / 2.11;
- char :
#"a";
ord(#"a");
chr(97);
- string :
"this is a string.";
size("this is a string");
"Good" ^ " morning.";
- tuple
(1, 2, 3)
("one", "two", "three")
(1, "two", false)
- #1 (1, "two", false);
val it = 1 : int
- #2 (1, "two", false);
val it = "two" : string
- list :
[1, 2, 3] (@ list of int @)
["one", "two", "three"] (@ list of string @)
[true, false, true] (@ list of boolean @)
[1, "two", false] (@ you can't compile this. type of all list's elements should be same @)
[1, 2, 3] @ [4, 5, 6] = [1, 2, 3, 4, 5, 6] = true (@ @ is list concatination operator @)