diff --git a/gitlab-pages/docs/language-basics/cheat-sheet.md b/gitlab-pages/docs/language-basics/cheat-sheet.md index 6f46a6b3f..4d8510cfa 100644 --- a/gitlab-pages/docs/language-basics/cheat-sheet.md +++ b/gitlab-pages/docs/language-basics/cheat-sheet.md @@ -31,7 +31,7 @@ title: Cheat Sheet |Assignment on an existing variable

*⚠️ This feature is not supported at the top-level scope, you can use it e.g. within functions. Works for Records and Maps as well.*| ```age := 18;```, ```p.age := 21``` | |Annotations| ```("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address)```| |Variants|
type action is
| Increment of int
| Decrement of int
| -|Variant *(pattern)* matching|
const a: action = Increment(5);
case a of
| Increment n -> n + 1
| Decrement n -> n - 1
end
| +|Variant *(pattern)* matching|
const a: action = Increment(5);
case a of
| Increment(n) -> n + 1
| Decrement(n) -> n - 1
end
| |Records|
type person is record
  age: int ;
  name: string ;
end

const john : person = record
  age = 18;
  name = "John Doe";
end

const name: string = john.name;
| |Maps|
type prices is map(nat, tez);

const prices : prices = map
  10n -> 60mtz;
  50n -> 30mtz;
  100n -> 10mtz;
end

const price: option(tez) = prices[50n];
| |Contracts & Accounts|
const destinationAddress : address = "tz1...";
const contract : contract(unit) = get_contract(destinationAddress);
| diff --git a/gitlab-pages/docs/language-basics/entrypoints.md b/gitlab-pages/docs/language-basics/entrypoints.md index 3f17189b7..e666f8c10 100644 --- a/gitlab-pages/docs/language-basics/entrypoints.md +++ b/gitlab-pages/docs/language-basics/entrypoints.md @@ -37,8 +37,8 @@ type action is function main (const action: action ; const counter: int) : (list(operation) * int) is block {skip} with ((nil : list(operation)), case action of - | Increment number -> counter + number - | Decrement number -> counter - number + | Increment(number) -> counter + number + | Decrement(number) -> counter - number end) ``` diff --git a/gitlab-pages/website/blog/2019-06-13-public-launch-of-ligo.md b/gitlab-pages/website/blog/2019-06-13-public-launch-of-ligo.md index 44e194eaf..f0caa55b8 100644 --- a/gitlab-pages/website/blog/2019-06-13-public-launch-of-ligo.md +++ b/gitlab-pages/website/blog/2019-06-13-public-launch-of-ligo.md @@ -34,8 +34,8 @@ type action is function main (const p : action ; const s : int) : (list(operation) * int) is block {skip} with ((nil : list(operation)), case p of - | Increment n -> s + n - | Decrement n -> s - n + | Increment(n) -> s + n + | Decrement(n) -> s - n end) ``` diff --git a/gitlab-pages/website/pages/en/index.js b/gitlab-pages/website/pages/en/index.js index 61f8255c8..77a161104 100644 --- a/gitlab-pages/website/pages/en/index.js +++ b/gitlab-pages/website/pages/en/index.js @@ -40,7 +40,7 @@ class HomeSplash extends React.Component {
-
// variant defining pseudo multi-entrypoint actions
type action is
| Increment of int
| Decrement of int

function add (const a : int ; const b : int) : int is
block {'{ skip }'} with a + b

function subtract (const a : int ; const b : int) : int is
block {'{ skip }'} with a - b

// real entrypoint that re-routes the flow based on the action provided
function main (const p : action ; const s : int) : (list(operation) * int) is
block {'{ skip }'} with ((nil : list(operation)),
case p of
| Increment n -> add(s, n)
| Decrement n -> subtract(s, n)
end)
+
// variant defining pseudo multi-entrypoint actions
type action is
| Increment of int
| Decrement of int

function add (const a : int ; const b : int) : int is
block {'{ skip }'} with a + b

function subtract (const a : int ; const b : int) : int is
block {'{ skip }'} with a - b

// real entrypoint that re-routes the flow based on the action provided
function main (const p : action ; const s : int) : (list(operation) * int) is
block {'{ skip }'} with ((nil : list(operation)),
case p of
| Increment(n) -> add(s, n)
| Decrement(n) -> subtract(s, n)
end)
diff --git a/src/contracts/website2.ligo b/src/contracts/website2.ligo index c58561aa9..141e57b41 100644 --- a/src/contracts/website2.ligo +++ b/src/contracts/website2.ligo @@ -13,6 +13,6 @@ function subtract (const a : int ; const b : int) : int is function main (const p : action ; const s : int) : (list(operation) * int) is block {skip} with ((nil : list(operation)), case p of - | Increment (n) -> add (s, n) - | Decrement (n) -> subtract (s, n) + | Increment(n) -> add(s, n) + | Decrement(n) -> subtract(s, n) end)