summaryrefslogtreecommitdiff
path: root/tests/jscomp.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-09-22 14:15:29 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-09-22 14:15:29 -0400
commit1782ad42006d1ff37ae3c818dbc25d713dd88e6b (patch)
tree4f6af43d27894091ed79d61f3202eacffd17fcfd /tests/jscomp.ur
parent79db9a612f96be267d5fe38cf27afeb0d29ad2ec (diff)
Compiled an 'option' pattern-match
Diffstat (limited to 'tests/jscomp.ur')
-rw-r--r--tests/jscomp.ur11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/jscomp.ur b/tests/jscomp.ur
index c283ae4d..1d5e3b54 100644
--- a/tests/jscomp.ur
+++ b/tests/jscomp.ur
@@ -1,6 +1,11 @@
fun fst [a] [b] (x : a) (y : b) = x
fun snd [a] [b] (x : a) (y : b) = y
+fun fact n =
+ case n of
+ 0 => 1
+ | _ => n * fact (n - 1)
+
fun main () =
s <- source "";
s' <- source "";
@@ -21,7 +26,11 @@ fun main () =
<button value="-" onclick={s <- get s; alert (show (-(readError s : int)))}/>
<button value="+1" onclick={s <- get s; alert (show (readError s + 1))}/>
<button value="*3" onclick={s <- get s; alert (show ((readError s) * 3))}/>
- <button value="f" onclick={s <- get s; f <- get f; alert (show (f (readError s)))}/><br/><br/>
+ <button value="!" onclick={s <- get s; alert (show (fact (readError s)))}/>
+ <button value="f" onclick={s <- get s; f <- get f; alert (show (f (readError s)))}/>
+ <button value="+1P" onclick={s <- get s; case read s of
+ None => alert "Nada!"
+ | Some (n : int) => alert (show (n + 1))}/>
<button value="f2" onclick={s <- get s; s' <- get s'; f2 <- get f2; alert (f2 s s')}/><br/><br/>