Mercurial > urweb
comparison tests/jscomp.ur @ 974:b851675a2c3d
Compiled an 'option' pattern-match
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 22 Sep 2009 14:15:29 -0400 |
parents | e30c2409c9d0 |
children | 8fe576c0bee9 |
comparison
equal
deleted
inserted
replaced
973:e30c2409c9d0 | 974:b851675a2c3d |
---|---|
1 fun fst [a] [b] (x : a) (y : b) = x | 1 fun fst [a] [b] (x : a) (y : b) = x |
2 fun snd [a] [b] (x : a) (y : b) = y | 2 fun snd [a] [b] (x : a) (y : b) = y |
3 | |
4 fun fact n = | |
5 case n of | |
6 0 => 1 | |
7 | _ => n * fact (n - 1) | |
3 | 8 |
4 fun main () = | 9 fun main () = |
5 s <- source ""; | 10 s <- source ""; |
6 s' <- source ""; | 11 s' <- source ""; |
7 f <- source (plus 1); | 12 f <- source (plus 1); |
19 | 24 |
20 <button value="Echo" onclick={s <- get s; alert s}/> | 25 <button value="Echo" onclick={s <- get s; alert s}/> |
21 <button value="-" onclick={s <- get s; alert (show (-(readError s : int)))}/> | 26 <button value="-" onclick={s <- get s; alert (show (-(readError s : int)))}/> |
22 <button value="+1" onclick={s <- get s; alert (show (readError s + 1))}/> | 27 <button value="+1" onclick={s <- get s; alert (show (readError s + 1))}/> |
23 <button value="*3" onclick={s <- get s; alert (show ((readError s) * 3))}/> | 28 <button value="*3" onclick={s <- get s; alert (show ((readError s) * 3))}/> |
24 <button value="f" onclick={s <- get s; f <- get f; alert (show (f (readError s)))}/><br/><br/> | 29 <button value="!" onclick={s <- get s; alert (show (fact (readError s)))}/> |
30 <button value="f" onclick={s <- get s; f <- get f; alert (show (f (readError s)))}/> | |
31 <button value="+1P" onclick={s <- get s; case read s of | |
32 None => alert "Nada!" | |
33 | Some (n : int) => alert (show (n + 1))}/> | |
25 | 34 |
26 <button value="f2" onclick={s <- get s; s' <- get s'; f2 <- get f2; alert (f2 s s')}/><br/><br/> | 35 <button value="f2" onclick={s <- get s; s' <- get s'; f2 <- get f2; alert (f2 s s')}/><br/><br/> |
27 | 36 |
28 <button value="A" onclick={r <- get r; alert r.A}/> | 37 <button value="A" onclick={r <- get r; alert r.A}/> |
29 <button value="B" onclick={r <- get r; alert r.B}/> | 38 <button value="B" onclick={r <- get r; alert r.B}/> |