2019-06-06 20:40:05 +04:00
|
|
|
type storage = int
|
|
|
|
|
|
|
|
type param =
|
|
|
|
Add of int
|
|
|
|
| Sub of int
|
|
|
|
|
|
|
|
let%entry main (p : param) storage =
|
|
|
|
let storage =
|
|
|
|
storage +
|
|
|
|
(match p with
|
|
|
|
Add n -> n
|
|
|
|
| Sub n -> 0-n)
|
|
|
|
in (([] : operation list), storage)
|
2019-10-29 08:38:29 +04:00
|
|
|
|
2019-10-29 09:01:31 +04:00
|
|
|
let match_bool (b: bool) : int =
|
|
|
|
match b with
|
|
|
|
true -> 10
|
|
|
|
| false -> 0
|
|
|
|
|
2019-10-29 08:38:29 +04:00
|
|
|
let match_list (l: int list) : int =
|
|
|
|
match l with
|
|
|
|
hd :: tl -> hd
|
|
|
|
| [] -> 10
|
|
|
|
|
2019-10-29 09:01:31 +04:00
|
|
|
let match_option (i : int option) : int =
|
|
|
|
match i with
|
|
|
|
Some n -> n
|
|
|
|
| None -> 0
|