Update Pascaligo parentheses in docs
This commit is contained in:
parent
2f6e17c837
commit
7492657790
@ -31,7 +31,7 @@ title: Cheat Sheet
|
||||
|Assignment on an existing variable <br/></br>*⚠️ 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|<pre><code>type action is<br/>| Increment of int<br/>| Decrement of int</code></pre>|
|
||||
|Variant *(pattern)* matching|<pre><code>const a: action = Increment(5);<br/>case a of<br/>| Increment n -> n + 1<br/>| Decrement n -> n - 1<br/>end</code></pre>|
|
||||
|Variant *(pattern)* matching|<pre><code>const a: action = Increment(5);<br/>case a of<br/>| Increment(n) -> n + 1<br/>| Decrement(n) -> n - 1<br/>end</code></pre>|
|
||||
|Records|<pre><code>type person is record<br/> age: int ;<br/> name: string ;<br/>end<br/><br/>const john : person = record<br/> age = 18;<br/> name = "John Doe";<br/>end<br/><br/>const name: string = john.name;</code></pre>|
|
||||
|Maps|<pre><code>type prices is map(nat, tez);<br/><br/>const prices : prices = map<br/> 10n -> 60mtz;<br/> 50n -> 30mtz;<br/> 100n -> 10mtz;<br/>end<br/><br/>const price: option(tez) = prices[50n];</code></pre>|
|
||||
|Contracts & Accounts|<pre><code>const destinationAddress : address = "tz1...";<br/>const contract : contract(unit) = get_contract(destinationAddress);</code></pre>|
|
||||
|
@ -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)
|
||||
```
|
||||
|
||||
|
@ -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)
|
||||
```
|
||||
|
||||
|
@ -40,7 +40,7 @@ class HomeSplash extends React.Component {
|
||||
<div id="tab-group-3-content-4" className="tab-pane active" data-group="group_3" tabIndex="-1">
|
||||
<div>
|
||||
<span>
|
||||
<pre><code className="hljs css language-Pascal">// variant defining pseudo multi-entrypoint actions<br />type action is<br />| Increment of int<br />| Decrement of int<br /><br />function add (const a : int ; const b : int) : int is<br /> block {'{ skip }'} with a + b<br /><br />function subtract (const a : int ; const b : int) : int is<br /> block {'{ skip }'} with a - b<br /><br />// real entrypoint that re-routes the flow based on the action provided<br />function main (const p : action ; const s : int) : (list(operation) * int) is<br /> block {'{ skip }'} with ((nil : list(operation)),<br /> case p of<br /> | Increment n -> add(s, n)<br /> | Decrement n -> subtract(s, n)<br /> end)<br /></code></pre>
|
||||
<pre><code className="hljs css language-Pascal">// variant defining pseudo multi-entrypoint actions<br />type action is<br />| Increment of int<br />| Decrement of int<br /><br />function add (const a : int ; const b : int) : int is<br /> block {'{ skip }'} with a + b<br /><br />function subtract (const a : int ; const b : int) : int is<br /> block {'{ skip }'} with a - b<br /><br />// real entrypoint that re-routes the flow based on the action provided<br />function main (const p : action ; const s : int) : (list(operation) * int) is<br /> block {'{ skip }'} with ((nil : list(operation)),<br /> case p of<br /> | Increment(n) -> add(s, n)<br /> | Decrement(n) -> subtract(s, n)<br /> end)<br /></code></pre>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user