Fix examples on front page of ligolang.org, add reminder to change in future

This commit is contained in:
John David Pressman 2020-01-20 19:42:22 -08:00
parent d351d585b0
commit 44dd39dcb2
3 changed files with 33 additions and 25 deletions

View File

@ -24,51 +24,51 @@ ${pre}`;
const CAMELIGO_EXAMPLE = `${pre}ocaml const CAMELIGO_EXAMPLE = `${pre}ocaml
type storage = int type storage = int
(* variant defining pseudo multi-entrypoint (* variant defining pseudo multi-entrypoint actions *)
actions *)
type action = type action =
| Increment of int | Increment of int
| Decrement of int | Decrement of int
let add (a: int) (b: int): int = a + b let add (a: int) (b: int) : int = a + b
let sub (a: int) (b: int) : int = a - b
let subtract (a: int) (b: int): int = a - b (* real entrypoint that re-routes the flow based on the action provided *)
(* real entrypoint that re-routes the flow let main (p,s: action * storage) =
based on the action provided *) let storage =
let%entry main(p : action) storage = match p with
let storage = | Increment n -> add s n
match p with | Decrement n -> sub s n
| Increment n -> add storage n in ([] : operation list), storage
| Decrement n -> subtract storage n
in (([] : operation list), storage)
${pre}`; ${pre}`;
const REASONLIGO_EXAMPLE = `${pre}reasonligo const REASONLIGO_EXAMPLE = `${pre}reasonligo
type storage = int; type storage = int;
/* variant defining pseudo multi-entrypoint /* variant defining pseudo multi-entrypoint actions */
actions */
type action = type action =
| Increment(int) | Increment(int)
| Decrement(int); | Decrement(int);
let add = (a: int, b: int): int => a + b; let add = (a: int, b: int): int => a + b;
let sub = (a: int, b: int): int => a - b;
let subtract = (a: int, b: int): int => a - b; /* real entrypoint that re-routes the flow based on the action provided */
/* real entrypoint that re-routes the flow let main2 = (p: action, storage) => {
based on the action provided */
let main = (p: action, storage) => {
let storage = let storage =
switch (p) { switch (p) {
| Increment(n) => add(storage, n) | Increment(n) => add(storage, n)
| Decrement(n) => subtract(storage, n) | Decrement(n) => sub(storage, n)
}; };
([]: list(operation), storage); ([]: list(operation), storage);
}; };
let main = (x: (action, storage)) => main2(x[0],x[1]);
${pre}`; ${pre}`;

View File

@ -1,3 +1,5 @@
(* IF YOU CHANGE THIS, CHANGE THE EXAMPLE ON THE FRONT PAGE OF THE WEBSITE *)
type storage = int type storage = int
(* variant defining pseudo multi-entrypoint actions *) (* variant defining pseudo multi-entrypoint actions *)
@ -11,9 +13,11 @@ let sub (a: int) (b: int) : int = a - b
(* real entrypoint that re-routes the flow based on the action provided *) (* real entrypoint that re-routes the flow based on the action provided *)
let main (ps: action * storage) = let main (p,s: action * storage) =
let storage = let storage =
match ps.0 with match p with
| Increment n -> add ps.1 n | Increment n -> add s n
| Decrement n -> sub ps.1 n | Decrement n -> sub s n
in ([] : operation list), storage in ([] : operation list), storage
(* IF YOU CHANGE THIS, CHANGE THE EXAMPLE ON THE FRONT PAGE OF THE WEBSITE *)

View File

@ -1,3 +1,5 @@
(* IF YOU CHANGE THIS, CHANGE THE EXAMPLE ON THE FRONT PAGE OF THE WEBSITE *)
type storage = int; type storage = int;
/* variant defining pseudo multi-entrypoint actions */ /* variant defining pseudo multi-entrypoint actions */
@ -21,3 +23,5 @@ let main2 = (p: action, storage) => {
}; };
let main = (x: (action, storage)) => main2(x[0],x[1]); let main = (x: (action, storage)) => main2(x[0],x[1]);
(* IF YOU CHANGE THIS, CHANGE THE EXAMPLE ON THE FRONT PAGE OF THE WEBSITE *)