diff options
author | Milo Gilad <milogaccnts@gmail.com> | 2017-08-25 10:18:31 -0400 |
---|---|---|
committer | Milo Gilad <milogaccnts@gmail.com> | 2017-08-25 10:18:31 -0400 |
commit | a6c3a64a4c897a1f7e7acfbfe6318866317770ad (patch) | |
tree | 28b0d35aaf2cdc3e968e182f1de4d5c5e596a970 /standard-ml.html.markdown | |
parent | 1abae4b25de43e05df3ba225986997bc72eb3f8a (diff) | |
parent | bce21489d8d7e3a3f3d4ede2154dba082647296e (diff) |
Merge branch 'master' of github.com:adambard/learnxinyminutes-docs
Diffstat (limited to 'standard-ml.html.markdown')
-rw-r--r-- | standard-ml.html.markdown | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/standard-ml.html.markdown b/standard-ml.html.markdown index c286366b..e1fe0d19 100644 --- a/standard-ml.html.markdown +++ b/standard-ml.html.markdown @@ -1,5 +1,6 @@ --- language: "Standard ML" +filename: standardml.sml contributors: - ["Simon Shine", "http://shine.eu.org/"] - ["David Pedersen", "http://lonelyproton.com/"] @@ -351,7 +352,10 @@ val _ = print (say(Red) ^ "\n") fun say Red = "You are red!" | say Green = "You are green!" | say Blue = "You are blue!" - | say _ = raise Fail "Unknown color" + +(* We did not include the match arm `say _ = raise Fail "Unknown color"` +because after specifying all three colors, the pattern is exhaustive +and redundancy is not permitted in pattern matching *) (* Here is a binary tree datatype *) @@ -395,7 +399,7 @@ fun failing_function [] = raise Empty (* used for empty lists *) | failing_function xs = raise Fail "This list is too long!" (* We can pattern match in 'handle' to make sure - a specfic exception was raised, or grab the message *) + a specific exception was raised, or grab the message *) val err_msg = failing_function [1,2] handle Fail _ => "Fail was raised" | Domain => "Domain was raised" | Empty => "Empty was raised" |