Merge branch 'docs/front-page-example-update' into 'dev'

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

See merge request ligolang/ligo!345
This commit is contained in:
John David Pressman 2020-01-21 10:18:43 +00:00
commit 56135ac711
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%entry main(p : action) storage =
let storage = let storage =
match p with match p with
| Increment n -> add storage n | Increment n -> add s n
| Decrement n -> subtract storage n | Decrement n -> sub s n
in (([] : operation list), storage) 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 *)