![]() Comments: (* This is a comment *) instead of /* This is a comment */.Strings: Caret ("^") concatenates two strings.Boolean logic: Use "andalso" and "orelse" "and" does something else (to be explained later).Use the function real to convert an int to a float, and use round, ceil, or floor to convert a float to an int. Writing "2 + 3.0" yields an error in SML. SML doesn't automatically convert between floats and ints.Integer division is performed by infix "div" (e.g., "5 div 2").Negation is performed by prefix "~" instead of prefix "-".Writing "foo(2, 3)" in SML means to apply the function foo to the tuple (2, 3). Function application: In SML, each function can be thought of as taking exactly one argument, although that argument can be a tuple.A few syntactic differences from C-like languages:. ![]() "val it = 4 : int" means that the value of the variable it is 4 and its type is int. The SML interpreter automatically introduces a new variable named "it" that contains the value of the last evaluated input line. (Don't forget the semicolon.) Your terminal should look like the ~]$ rlwrap sml
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |