diff options
author | Geoffrey Liu <g-liu@users.noreply.github.com> | 2016-06-26 21:21:13 +0800 |
---|---|---|
committer | ven <vendethiel@hotmail.fr> | 2016-06-26 15:21:13 +0200 |
commit | 273fa8606b662dbec5b3b0b2fd0d3dfd648e00ab (patch) | |
tree | 8f56cb4b9774155d973e57e07b807a0afc1ee212 /standard-ml.html.markdown | |
parent | 19ac1e8eeb92115b1af90ea1aa9181a8f6d48211 (diff) |
[racket/en] Add more details about Racket (#2278)
* Add let* and letrec reference
* More elaboration on structs
* Add code about predefined car, cdr functions
* Mention explicit typing, int to real conversion
Diffstat (limited to 'standard-ml.html.markdown')
-rw-r--r-- | standard-ml.html.markdown | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/standard-ml.html.markdown b/standard-ml.html.markdown index 143980e7..133e4f54 100644 --- a/standard-ml.html.markdown +++ b/standard-ml.html.markdown @@ -24,6 +24,12 @@ val phone_no = 5551337 val pi = 3.14159 val negative_number = ~15 (* Yeah, unary minus uses the 'tilde' symbol *) +(* Optionally, you can explicitly declare types. This is not necessary as + ML will automatically figure out the types of your values. *) +val diameter = 7926 : int +val e = 2.718 : real +val name = "Bobby" : string + (* And just as importantly, functions: *) fun is_large(x : int) = if x > 37 then true else false @@ -31,6 +37,8 @@ fun is_large(x : int) = if x > 37 then true else false val tau = 2.0 * pi (* You can multiply two reals *) val twice_rent = 2 * rent (* You can multiply two ints *) (* val meh = 1.25 * 10 *) (* But you can't multiply an int and a real *) +val yeh = 1.25 * (Real.fromInt 10) (* ...unless you explicitly convert + one or the other *) (* +, - and * are overloaded so they work for both int and real. *) (* The same cannot be said for division which has separate operators: *) |