diff options
| author | Pratik Karki <predatoramigo@gmail.com> | 2018-02-28 16:17:52 +0545 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-28 16:17:52 +0545 | 
| commit | 3b0a97df42f13beaf4c867412d1477bee501c515 (patch) | |
| tree | 2c796932886a9a09fef8dc8151ab11bdf7f20800 | |
| parent | a26d106ed72e7d4a391e73496cc65e0f7b559111 (diff) | |
| parent | 9999a30e045f59fe3347b8822f71fff32b3ffc27 (diff) | |
Merge pull request #3037 from twopoint718/master
[Standard ML/en] Add case expression to SML docs
| -rw-r--r-- | standard-ml.html.markdown | 11 | 
1 files changed, 11 insertions, 0 deletions
| diff --git a/standard-ml.html.markdown b/standard-ml.html.markdown index 5db15b5c..b34f1c08 100644 --- a/standard-ml.html.markdown +++ b/standard-ml.html.markdown @@ -6,6 +6,7 @@ contributors:      - ["David Pedersen", "http://lonelyproton.com/"]      - ["James Baker", "http://www.jbaker.io/"]      - ["Leo Zovic", "http://langnostic.inaimathi.ca/"] +    - ["Chris Wilson", "http://sencjw.com/"]  ---  Standard ML is a functional programming language with type inference and some @@ -266,6 +267,16 @@ fun second_elem (x::y::xs) = y  fun evenly_positioned_elems (odd::even::xs) = even::evenly_positioned_elems xs    | evenly_positioned_elems [odd] = []  (* Base case: throw away *)    | evenly_positioned_elems []    = []  (* Base case *) +   +(* The case expression can also be used to pattern match and return a value *) +datatype temp = +      C of real +    | F of real + +fun temp_to_f t = +    case t of +      C x => x * (9.0 / 5.0) + 32.0 +    | F x => x  (* When matching on records, you must use their slot names, and you must bind     every slot in a record. The order of the slots doesn't matter though. *) | 
