Merge branch 'docs/update-front-page-examples-2' into 'dev'
Update CameLIGO and ReasonLIGO examples on front page so they're usable in the IDE See merge request ligolang/ligo!347
This commit is contained in:
commit
eba4901a76
@ -30,16 +30,16 @@ 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,b: int * int) : int = a + b
|
||||||
let sub (a: int) (b: int) : int = a - b
|
let sub (a,b: int * 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 (p,s: action * storage) =
|
let main (p,s: action * storage) =
|
||||||
let storage =
|
let storage =
|
||||||
match p with
|
match p with
|
||||||
| Increment n -> add s n
|
| Increment n -> add (s, n)
|
||||||
| Decrement n -> sub s n
|
| Decrement n -> sub (s, n)
|
||||||
in ([] : operation list), storage
|
in ([] : operation list), storage
|
||||||
${pre}`;
|
${pre}`;
|
||||||
|
|
||||||
@ -53,22 +53,19 @@ type action =
|
|||||||
| Increment(int)
|
| Increment(int)
|
||||||
| Decrement(int);
|
| Decrement(int);
|
||||||
|
|
||||||
let add = (a: int, b: int): int => a + b;
|
let add = ((a,b): (int, int)): int => a + b;
|
||||||
let sub = (a: int, b: int): int => a - b;
|
let sub = ((a,b): (int, 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 main2 = (p: action, storage) => {
|
let main = ((p,storage): (action, storage)) => {
|
||||||
let storage =
|
let storage =
|
||||||
switch (p) {
|
switch (p) {
|
||||||
| Increment(n) => add(storage, n)
|
| Increment(n) => add((storage, n))
|
||||||
| Decrement(n) => sub(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}`;
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,16 +8,16 @@ 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,b: int * int) : int = a + b
|
||||||
let sub (a: int) (b: int) : int = a - b
|
let sub (a,b: int * 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 (p,s: action * storage) =
|
let main (p,s: action * storage) =
|
||||||
let storage =
|
let storage =
|
||||||
match p with
|
match p with
|
||||||
| Increment n -> add s n
|
| Increment n -> add (s, n)
|
||||||
| Decrement n -> sub s 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 *)
|
(* IF YOU CHANGE THIS, CHANGE THE EXAMPLE ON THE FRONT PAGE OF THE WEBSITE *)
|
||||||
|
@ -8,20 +8,18 @@ type action =
|
|||||||
| Increment(int)
|
| Increment(int)
|
||||||
| Decrement(int);
|
| Decrement(int);
|
||||||
|
|
||||||
let add = (a: int, b: int): int => a + b;
|
let add = ((a,b): (int, int)): int => a + b;
|
||||||
let sub = (a: int, b: int): int => a - b;
|
let sub = ((a,b): (int, 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 main2 = (p: action, storage) => {
|
let main = ((p,storage): (action, storage)) => {
|
||||||
let storage =
|
let storage =
|
||||||
switch (p) {
|
switch (p) {
|
||||||
| Increment(n) => add(storage, n)
|
| Increment(n) => add((storage, n))
|
||||||
| Decrement(n) => sub(storage, n)
|
| Decrement(n) => sub((storage, n))
|
||||||
};
|
};
|
||||||
([]: list(operation), storage);
|
([]: list(operation), storage);
|
||||||
};
|
};
|
||||||
|
|
||||||
let main = (x: (action, storage)) => main2(x[0],x[1]);
|
|
||||||
|
|
||||||
(* IF YOU CHANGE THIS, CHANGE THE EXAMPLE ON THE FRONT PAGE OF THE WEBSITE *)
|
(* IF YOU CHANGE THIS, CHANGE THE EXAMPLE ON THE FRONT PAGE OF THE WEBSITE *)
|
||||||
|
Loading…
Reference in New Issue
Block a user