summaryrefslogtreecommitdiffhomepage
path: root/standard-ml.html.markdown
diff options
context:
space:
mode:
authorDivay Prakash <divayprakash@users.noreply.github.com>2018-10-24 11:04:05 +0530
committerGitHub <noreply@github.com>2018-10-24 11:04:05 +0530
commit4a7d678c2553bc379542a5901177b8bb2730ce65 (patch)
treeb2896f9f02b5a752f860a71a36b1e16c566a8ed7 /standard-ml.html.markdown
parente2949649f054ca069e95a05b04d99bccc30ba45d (diff)
parent8f5a67190705c9a3101653901d8f8a7b48eb1775 (diff)
Merge branch 'master' into master
Diffstat (limited to 'standard-ml.html.markdown')
-rw-r--r--standard-ml.html.markdown11
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. *)