Skip to content

Instantly share code, notes, and snippets.

@Y4suyuki
Last active August 28, 2016 23:56
Show Gist options
  • Save Y4suyuki/6793265 to your computer and use it in GitHub Desktop.
Save Y4suyuki/6793265 to your computer and use it in GitHub Desktop.
Coursera Programming Language SML/NJ cheatsheet

#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 @)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment