2020-06-03 12:41:26 +02:00
|
|
|
type storage = int;
|
|
|
|
|
|
|
|
type parameter = Add(int) | Sub(int);
|
|
|
|
|
|
|
|
type return = (list(operation), storage);
|
|
|
|
|
|
|
|
let main =
|
2020-06-05 13:56:14 +02:00
|
|
|
((action, store): (parameter, storage)) => {
|
|
|
|
let store =
|
|
|
|
store + (switch(action) {
|
|
|
|
| Add(n) => n
|
|
|
|
| Sub(n) => -n
|
|
|
|
});
|
|
|
|
(([] : list(operation)), store)
|
|
|
|
};
|