Merge branch 'syntax-toggle' into 'dev'
Docusaurus 2 + site wide syntax toggle See merge request ligolang/ligo!468
This commit is contained in:
commit
72bc251868
@ -1,4 +1,4 @@
|
|||||||
FROM node:8.11.4
|
FROM node:12.16
|
||||||
|
|
||||||
WORKDIR /app/website
|
WORKDIR /app/website
|
||||||
|
|
||||||
|
@ -8,15 +8,16 @@ services:
|
|||||||
- 35729:35729
|
- 35729:35729
|
||||||
volumes:
|
volumes:
|
||||||
- ./docs:/app/docs
|
- ./docs:/app/docs
|
||||||
- ./website/blog:/app/website/blog
|
# - ./website/blog:/app/website/blog
|
||||||
- ./website/core:/app/website/core
|
- ./website/core:/app/website/core
|
||||||
- ./website/i18n:/app/website/i18n
|
# - ./website/i18n:/app/website/i18n
|
||||||
- ./website/pages:/app/website/pages
|
- ./website/src:/app/website/src
|
||||||
- ./website/static:/app/website/static
|
- ./website/static:/app/website/static
|
||||||
- ./website/versioned_sidebars:/app/website/versioned_sidebars
|
# - ./website/versioned_sidebars:/app/website/versioned_sidebars
|
||||||
- ./website/versioned_docs:/app/website/versioned_docs
|
# - ./website/versioned_docs:/app/website/versioned_docs
|
||||||
- ./website/sidebars.json:/app/website/sidebars.json
|
- ./website/sidebars.json:/app/website/sidebars.json
|
||||||
- ./website/siteConfig.js:/app/website/siteConfig.js
|
- ./website/docusaurus.config.js:/app/website/docusaurus.config.js
|
||||||
- ./website/versions.json:/app/website/versions.json
|
- ./website/versions.json:/app/website/versions.json
|
||||||
- ./website/node_modules/reason-highlightjs:/app/website/node_modules/reason-highlightjs
|
# - ./website/core/AlgoliaSearch.js:/app/website/core/AlgoliaSearch.js
|
||||||
|
|
||||||
working_dir: /app/website
|
working_dir: /app/website
|
||||||
|
@ -3,6 +3,8 @@ id: entrypoints-contracts
|
|||||||
title: Main function and Entrypoints
|
title: Main function and Entrypoints
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
## Access Functions
|
## Access Functions
|
||||||
|
|
||||||
A LIGO contract is made of a series of constant and function
|
A LIGO contract is made of a series of constant and function
|
||||||
@ -22,25 +24,33 @@ type of a main function is as follows, assuming that the type
|
|||||||
`storage` has been defined elsewhere. (Note that you can use any type
|
`storage` has been defined elsewhere. (Note that you can use any type
|
||||||
with any name for the storage.)
|
with any name for the storage.)
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo skip
|
```pascaligo skip
|
||||||
type storage is ... // Any name, any type
|
type storage is ... // Any name, any type
|
||||||
type return is list (operation) * storage
|
type return is list (operation) * storage
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo skip
|
```cameligo skip
|
||||||
type storage = ... // Any name, any type
|
type storage = ... // Any name, any type
|
||||||
type return = operation list * storage
|
type return = operation list * storage
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo skip
|
```reasonligo skip
|
||||||
type storage = ...; // Any name, any type
|
type storage = ...; // Any name, any type
|
||||||
type return = (list (operation), storage);
|
type return = (list (operation), storage);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
The contract storage can only be modified by activating a main
|
The contract storage can only be modified by activating a main
|
||||||
function: given the state of the storage *on-chain*, a main function
|
function: given the state of the storage *on-chain*, a main function
|
||||||
@ -50,9 +60,9 @@ contract's parameter.
|
|||||||
Here is an example where the storage is a single natural number that
|
Here is an example where the storage is a single natural number that
|
||||||
is updated by the parameter.
|
is updated by the parameter.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=a
|
```pascaligo group=a
|
||||||
type parameter is nat
|
type parameter is nat
|
||||||
@ -62,8 +72,9 @@ type return is list (operation) * storage
|
|||||||
function save (const action : parameter; const store : storage) : return is
|
function save (const action : parameter; const store : storage) : return is
|
||||||
((nil : list (operation)), store)
|
((nil : list (operation)), store)
|
||||||
```
|
```
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
<!--CameLIGO-->
|
|
||||||
```cameligo group=a
|
```cameligo group=a
|
||||||
type parameter = nat
|
type parameter = nat
|
||||||
type storage = nat
|
type storage = nat
|
||||||
@ -73,7 +84,9 @@ let save (action, store: parameter * storage) : return =
|
|||||||
(([] : operation list), store)
|
(([] : operation list), store)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=a
|
```reasonligo group=a
|
||||||
type parameter = nat;
|
type parameter = nat;
|
||||||
type storage = nat;
|
type storage = nat;
|
||||||
@ -82,7 +95,9 @@ type return = (list (operation), storage);
|
|||||||
let main = ((action, store): (parameter, storage)) : return =>
|
let main = ((action, store): (parameter, storage)) : return =>
|
||||||
(([] : list (operation)), store);
|
(([] : list (operation)), store);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Entrypoints
|
## Entrypoints
|
||||||
|
|
||||||
@ -105,9 +120,10 @@ In the following example, the storage contains a counter of type `nat`
|
|||||||
and a name of type `string`. Depending on the parameter of the
|
and a name of type `string`. Depending on the parameter of the
|
||||||
contract, either the counter or the name is updated.
|
contract, either the counter or the name is updated.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=b
|
```pascaligo group=b
|
||||||
type parameter is
|
type parameter is
|
||||||
Action_A of nat
|
Action_A of nat
|
||||||
@ -133,7 +149,9 @@ function main (const action : parameter; const store : storage): return is
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=b
|
```cameligo group=b
|
||||||
type parameter =
|
type parameter =
|
||||||
Action_A of nat
|
Action_A of nat
|
||||||
@ -158,7 +176,9 @@ let main (action, store: parameter * storage) : return =
|
|||||||
| Action_B s -> entry_B (s, store)
|
| Action_B s -> entry_B (s, store)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=b
|
```reasonligo group=b
|
||||||
type parameter =
|
type parameter =
|
||||||
| Action_A (nat)
|
| Action_A (nat)
|
||||||
@ -183,7 +203,9 @@ let main = ((action, store): (parameter, storage)) : return =>
|
|||||||
| Action_B (s) => entry_B ((s, store))
|
| Action_B (s) => entry_B ((s, store))
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Tezos-specific Built-ins
|
## Tezos-specific Built-ins
|
||||||
@ -198,8 +220,9 @@ This example shows how `Tezos.amount` and `failwith` can be used to
|
|||||||
decline any transaction that sends more tez than `0tez`, that is, no
|
decline any transaction that sends more tez than `0tez`, that is, no
|
||||||
incoming tokens are accepted.
|
incoming tokens are accepted.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=c
|
```pascaligo group=c
|
||||||
type parameter is unit
|
type parameter is unit
|
||||||
type storage is unit
|
type storage is unit
|
||||||
@ -213,7 +236,10 @@ function deny (const action : parameter; const store : storage) : return is
|
|||||||
|
|
||||||
> Note that `amount` is *deprecated*.
|
> Note that `amount` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=c
|
```cameligo group=c
|
||||||
type parameter = unit
|
type parameter = unit
|
||||||
type storage = unit
|
type storage = unit
|
||||||
@ -227,7 +253,9 @@ let deny (action, store : parameter * storage) : return =
|
|||||||
|
|
||||||
> Note that `amount` is *deprecated*.
|
> Note that `amount` is *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=c
|
```reasonligo group=c
|
||||||
type parameter = unit;
|
type parameter = unit;
|
||||||
type storage = unit;
|
type storage = unit;
|
||||||
@ -242,15 +270,17 @@ let deny = ((action, store): (parameter, storage)) : return => {
|
|||||||
|
|
||||||
> Note that `amount` is *deprecated*.
|
> Note that `amount` is *deprecated*.
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Access Control
|
### Access Control
|
||||||
|
|
||||||
This example shows how `Tezos.source` can be used to deny access to an
|
This example shows how `Tezos.source` can be used to deny access to an
|
||||||
entrypoint.
|
entrypoint.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=c
|
```pascaligo group=c
|
||||||
const owner : address = ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address);
|
const owner : address = ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address);
|
||||||
|
|
||||||
@ -261,7 +291,9 @@ function main (const action : parameter; const store : storage) : return is
|
|||||||
|
|
||||||
> Note that `source` is *deprecated*.
|
> Note that `source` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=c
|
```cameligo group=c
|
||||||
let owner : address = ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address)
|
let owner : address = ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address)
|
||||||
|
|
||||||
@ -272,7 +304,9 @@ let main (action, store: parameter * storage) : return =
|
|||||||
|
|
||||||
> Note that `source` is *deprecated*.
|
> Note that `source` is *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=c
|
```reasonligo group=c
|
||||||
let owner : address = ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address);
|
let owner : address = ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address);
|
||||||
|
|
||||||
@ -284,7 +318,8 @@ let main = ((action, store) : (parameter, storage)) : storage => {
|
|||||||
|
|
||||||
> Note that `source` is *deprecated*.
|
> Note that `source` is *deprecated*.
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Inter-Contract Invocations
|
### Inter-Contract Invocations
|
||||||
|
|
||||||
@ -310,9 +345,10 @@ of type `parameter`, and we have a `proxy.ligo` contract that accepts
|
|||||||
the same parameter type, and forwards the call to the deployed counter
|
the same parameter type, and forwards the call to the deployed counter
|
||||||
contract.
|
contract.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo skip
|
```pascaligo skip
|
||||||
// counter.ligo
|
// counter.ligo
|
||||||
type parameter is
|
type parameter is
|
||||||
@ -354,7 +390,9 @@ function proxy (const action : parameter; const store : storage): return is
|
|||||||
} with (ops, store)
|
} with (ops, store)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo skip
|
```cameligo skip
|
||||||
// counter.mligo
|
// counter.mligo
|
||||||
|
|
||||||
@ -395,7 +433,8 @@ let proxy (action, store : parameter * storage) : return =
|
|||||||
> Note that `Operation.get_contract` and `Operation.transaction` are
|
> Note that `Operation.get_contract` and `Operation.transaction` are
|
||||||
> *deprecated*.
|
> *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
```reasonligo skip
|
```reasonligo skip
|
||||||
// counter.religo
|
// counter.religo
|
||||||
|
|
||||||
@ -438,4 +477,5 @@ let proxy = ((action, store): (parameter, storage)) : return => {
|
|||||||
> Note that `Operation.get_contract` and `Operation.transaction` are
|
> Note that `Operation.get_contract` and `Operation.transaction` are
|
||||||
> *deprecated*.
|
> *deprecated*.
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ id: first-contract
|
|||||||
title: First contract
|
title: First contract
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
So far so good, we have learned enough of the LIGO language, we are
|
So far so good, we have learned enough of the LIGO language, we are
|
||||||
confident enough to write out first smart contract.
|
confident enough to write out first smart contract.
|
||||||
|
|
||||||
@ -23,16 +25,15 @@ following:
|
|||||||
|
|
||||||
Here is a full example:
|
Here is a full example:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--Pascaligo-->
|
```shell
|
||||||
```
|
|
||||||
ligo dry-run src/basic.ligo main Unit Unit
|
ligo dry-run src/basic.ligo main Unit Unit
|
||||||
// Outputs:
|
// Outputs:
|
||||||
// tuple[ list[]
|
// tuple[ list[]
|
||||||
// Unit
|
// Unit
|
||||||
// ]
|
// ]
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
Output of the `dry-run` is the return value of our main function, we
|
Output of the `dry-run` is the return value of our main function, we
|
||||||
can see the operations emitted (in our case an empty list, and the new
|
can see the operations emitted (in our case an empty list, and the new
|
||||||
@ -45,9 +46,9 @@ will accept an `action` variant in order to re-route our single `main`
|
|||||||
function to two entrypoints for `add` (addition) and `sub`
|
function to two entrypoints for `add` (addition) and `sub`
|
||||||
(subtraction).
|
(subtraction).
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
<Syntax syntax="pascaligo">
|
||||||
<!--Pascaligo-->
|
|
||||||
```
|
```pascaligo
|
||||||
type parameter is
|
type parameter is
|
||||||
Increment of int
|
Increment of int
|
||||||
| Decrement of int
|
| Decrement of int
|
||||||
@ -67,7 +68,9 @@ function main (const action : parameter; const store : storage) : return is
|
|||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
type parameter =
|
type parameter =
|
||||||
Increment of int
|
Increment of int
|
||||||
@ -87,7 +90,10 @@ let main (action, store : parameter * storage) : operation list * storage =
|
|||||||
| Decrement n -> sub (n, store)))
|
| Decrement n -> sub (n, store)))
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
type parameter =
|
type parameter =
|
||||||
Increment (int)
|
Increment (int)
|
||||||
@ -109,21 +115,18 @@ let main = ((action, store) : (parameter, storage)) : return =>
|
|||||||
}));
|
}));
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
To dry-run the counter contract, we will provide the `main` function
|
To dry-run the counter contract, we will provide the `main` function
|
||||||
with a variant parameter of value `Increment (5)` and an initial
|
with a variant parameter of value `Increment (5)` and an initial
|
||||||
storage value of `5`.
|
storage value of `5`.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
```shell
|
||||||
<!--Pascaligo-->
|
|
||||||
```
|
|
||||||
ligo dry-run src/counter.ligo main "Increment(5)" 5
|
ligo dry-run src/counter.ligo main "Increment(5)" 5
|
||||||
// tuple[ list[]
|
// tuple[ list[]
|
||||||
// 10
|
// 10
|
||||||
// ]
|
// ]
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
|
|
||||||
Our contract's storage has been successfuly incremented to `10`.
|
Our contract's storage has been successfuly incremented to `10`.
|
||||||
@ -134,19 +137,14 @@ In order to deploy the counter contract to a real Tezos network, we'd
|
|||||||
have to compile it first, this can be done with the help of the
|
have to compile it first, this can be done with the help of the
|
||||||
`compile-contract` CLI command:
|
`compile-contract` CLI command:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
```shell
|
||||||
<!--Pascaligo-->
|
|
||||||
```
|
|
||||||
ligo compile-contract src/counter.ligo main
|
ligo compile-contract src/counter.ligo main
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
|
|
||||||
Command above will output the following Michelson code:
|
Command above will output the following Michelson code:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--Pascaligo-->
|
```michelson
|
||||||
```
|
|
||||||
{ parameter (or (int %decrement) (int %increment)) ;
|
{ parameter (or (int %decrement) (int %increment)) ;
|
||||||
storage int ;
|
storage int ;
|
||||||
code { DUP ;
|
code { DUP ;
|
||||||
@ -175,20 +173,16 @@ Command above will output the following Michelson code:
|
|||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DROP 2 } } }
|
DIP { DROP 2 } } }
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
However in order to originate a Michelson contract on Tezos, we also
|
However in order to originate a Michelson contract on Tezos, we also
|
||||||
need to provide the initial storage value, we can use
|
need to provide the initial storage value, we can use
|
||||||
`compile-storage` to compile the LIGO representation of the storage to
|
`compile-storage` to compile the LIGO representation of the storage to
|
||||||
Michelson.
|
Michelson.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
```shell
|
||||||
<!--Pascaligo-->
|
|
||||||
```
|
|
||||||
ligo compile-storage src/counter.ligo main 5
|
ligo compile-storage src/counter.ligo main 5
|
||||||
// Outputs: 5
|
// Outputs: 5
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
In our case the LIGO storage value maps 1:1 to its Michelson
|
In our case the LIGO storage value maps 1:1 to its Michelson
|
||||||
representation, however this will not be the case once the parameter
|
representation, however this will not be the case once the parameter
|
||||||
@ -200,13 +194,11 @@ Same rules apply for parameters, as apply for translating LIGO storage
|
|||||||
values to Michelson. We will need to use `compile-parameter` to
|
values to Michelson. We will need to use `compile-parameter` to
|
||||||
compile our `action` variant into Michelson, here's how:
|
compile our `action` variant into Michelson, here's how:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
```shell
|
||||||
<!--Pascaligo-->
|
|
||||||
```
|
|
||||||
ligo compile-parameter src/counter.ligo main 'Increment(5)'
|
ligo compile-parameter src/counter.ligo main 'Increment(5)'
|
||||||
// Outputs: (Right 5)
|
// Outputs: (Right 5)
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
Now we can use `(Right 5)` which is a Michelson value, to invoke our
|
Now we can use `(Right 5)` which is a Michelson value, to invoke our
|
||||||
contract - e.g., via `tezos-client`
|
contract - e.g., via `tezos-client`
|
||||||
|
@ -3,6 +3,8 @@ id: include
|
|||||||
title: Including Other Contracts
|
title: Including Other Contracts
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
Let us say that we have a contract that is getting a too large. If it
|
Let us say that we have a contract that is getting a too large. If it
|
||||||
has a modular structure, you might find it useful to use the
|
has a modular structure, you might find it useful to use the
|
||||||
`#include` statement to split the contract up over multiple files.
|
`#include` statement to split the contract up over multiple files.
|
||||||
@ -10,9 +12,10 @@ has a modular structure, you might find it useful to use the
|
|||||||
You take the code that you want to include and put it in a separate
|
You take the code that you want to include and put it in a separate
|
||||||
file, for example `included.ligo`:
|
file, for example `included.ligo`:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
|
|
||||||
// Demonstrate PascaLIGO inclusion statements, see includer.ligo
|
// Demonstrate PascaLIGO inclusion statements, see includer.ligo
|
||||||
@ -20,46 +23,57 @@ file, for example `included.ligo`:
|
|||||||
const foo : int = 144
|
const foo : int = 144
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
// Demonstrate CameLIGO inclusion statements, see includer.mligo
|
// Demonstrate CameLIGO inclusion statements, see includer.mligo
|
||||||
|
|
||||||
let foo : int = 144
|
let foo : int = 144
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
// Demonstrate ReasonLIGO inclusion statements, see includer.religo
|
// Demonstrate ReasonLIGO inclusion statements, see includer.religo
|
||||||
|
|
||||||
let foo : int = 144;
|
let foo : int = 144;
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
And then you can include this code using the `#include` statement like so:
|
And then you can include this code using the `#include` statement like so:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
#include "included.ligo"
|
#include "included.ligo"
|
||||||
|
|
||||||
const bar : int = foo
|
const bar : int = foo
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
#include "included.mligo"
|
#include "included.mligo"
|
||||||
|
|
||||||
let bar : int = foo
|
let bar : int = foo
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
#include "included.religo"
|
#include "included.religo"
|
||||||
|
|
||||||
let bar : int = foo;
|
let bar : int = foo;
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ id: timestamps-addresses
|
|||||||
title: Timestamps, Addresses
|
title: Timestamps, Addresses
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
## Timestamps
|
## Timestamps
|
||||||
|
|
||||||
LIGO features timestamps, as Michelson does, while bakers baking the
|
LIGO features timestamps, as Michelson does, while bakers baking the
|
||||||
@ -15,29 +17,35 @@ You can obtain the current time using the built-in syntax specific
|
|||||||
expression, please be aware that it is up to the baker to set the
|
expression, please be aware that it is up to the baker to set the
|
||||||
current timestamp value.
|
current timestamp value.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=a
|
```pascaligo group=a
|
||||||
const today : timestamp = Tezos.now
|
const today : timestamp = Tezos.now
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `now` is *deprecated*.
|
> Note that `now` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=a
|
```cameligo group=a
|
||||||
let today : timestamp = Tezos.now
|
let today : timestamp = Tezos.now
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `Current.time` is *deprecated*.
|
> Note that `Current.time` is *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=a
|
```reasonligo group=a
|
||||||
let today : timestamp = Tezos.now;
|
let today : timestamp = Tezos.now;
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `Current.time` is *deprecated*.
|
> Note that `Current.time` is *deprecated*.
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
> When running code, the LIGO CLI option `--predecessor-timestamp`
|
> When running code, the LIGO CLI option `--predecessor-timestamp`
|
||||||
> allows you to control what `Tezos.now` returns.
|
> allows you to control what `Tezos.now` returns.
|
||||||
@ -49,8 +57,9 @@ constraints on your smart contracts. Consider the following scenarios.
|
|||||||
|
|
||||||
#### In 24 hours
|
#### In 24 hours
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=b
|
```pascaligo group=b
|
||||||
const today : timestamp = Tezos.now
|
const today : timestamp = Tezos.now
|
||||||
const one_day : int = 86400
|
const one_day : int = 86400
|
||||||
@ -61,7 +70,9 @@ const one_day_later : timestamp = some_date + one_day
|
|||||||
|
|
||||||
> Note that `now` is *deprecated*.
|
> Note that `now` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=b
|
```cameligo group=b
|
||||||
let today : timestamp = Tezos.now
|
let today : timestamp = Tezos.now
|
||||||
let one_day : int = 86400
|
let one_day : int = 86400
|
||||||
@ -72,7 +83,9 @@ let one_day_later : timestamp = some_date + one_day
|
|||||||
|
|
||||||
> Note that `Current.time` is *deprecated*.
|
> Note that `Current.time` is *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=b
|
```reasonligo group=b
|
||||||
let today : timestamp = Tezos.now;
|
let today : timestamp = Tezos.now;
|
||||||
let one_day : int = 86400;
|
let one_day : int = 86400;
|
||||||
@ -83,12 +96,14 @@ let one_day_later : timestamp = some_date + one_day;
|
|||||||
|
|
||||||
> Note that `Current.time` is *deprecated*.
|
> Note that `Current.time` is *deprecated*.
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
#### 24 hours Ago
|
#### 24 hours Ago
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=c
|
```pascaligo group=c
|
||||||
const today : timestamp = Tezos.now
|
const today : timestamp = Tezos.now
|
||||||
const one_day : int = 86400
|
const one_day : int = 86400
|
||||||
@ -97,7 +112,9 @@ const in_24_hrs : timestamp = today - one_day
|
|||||||
|
|
||||||
> Note that `now` is *deprecated*.
|
> Note that `now` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=c
|
```cameligo group=c
|
||||||
let today : timestamp = Tezos.now
|
let today : timestamp = Tezos.now
|
||||||
let one_day : int = 86400
|
let one_day : int = 86400
|
||||||
@ -106,7 +123,9 @@ let in_24_hrs : timestamp = today - one_day
|
|||||||
|
|
||||||
> Note that `Current.time` is *deprecated*.
|
> Note that `Current.time` is *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=c
|
```reasonligo group=c
|
||||||
let today : timestamp = Tezos.now;
|
let today : timestamp = Tezos.now;
|
||||||
let one_day : int = 86400;
|
let one_day : int = 86400;
|
||||||
@ -115,38 +134,43 @@ let in_24_hrs : timestamp = today - one_day;
|
|||||||
|
|
||||||
> Note that `Current.time` is *deprecated*.
|
> Note that `Current.time` is *deprecated*.
|
||||||
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
### Comparing Timestamps
|
### Comparing Timestamps
|
||||||
|
|
||||||
You can compare timestamps using the same comparison operators
|
You can compare timestamps using the same comparison operators
|
||||||
applying to numbers.
|
applying to numbers.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=c
|
```pascaligo group=c
|
||||||
const not_tommorow : bool = (Tezos.now = in_24_hrs)
|
const not_tommorow : bool = (Tezos.now = in_24_hrs)
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `now` is *deprecated*.
|
> Note that `now` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=c
|
```cameligo group=c
|
||||||
let not_tomorrow : bool = (Tezos.now = in_24_hrs)
|
let not_tomorrow : bool = (Tezos.now = in_24_hrs)
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `Current.time` is *deprecated*.
|
> Note that `Current.time` is *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=c
|
```reasonligo group=c
|
||||||
let not_tomorrow : bool = (Tezos.now == in_24_hrs);
|
let not_tomorrow : bool = (Tezos.now == in_24_hrs);
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `Current.time` is *deprecated*.
|
> Note that `Current.time` is *deprecated*.
|
||||||
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
## Addresses
|
## Addresses
|
||||||
|
|
||||||
@ -155,26 +179,32 @@ KT1, ...). Currently, addresses are created by casting a string to the
|
|||||||
`address` type. Beware of failures if the address is invalid. Consider
|
`address` type. Beware of failures if the address is invalid. Consider
|
||||||
the following examples.
|
the following examples.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=d
|
```pascaligo group=d
|
||||||
const my_account : address =
|
const my_account : address =
|
||||||
("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address)
|
("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=d
|
```cameligo group=d
|
||||||
let my_account : address =
|
let my_account : address =
|
||||||
("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address)
|
("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=d
|
```reasonligo group=d
|
||||||
let my_account : address =
|
let my_account : address =
|
||||||
("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address);
|
("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Signatures
|
## Signatures
|
||||||
|
|
||||||
@ -184,26 +214,35 @@ failure if the signature is invalid.
|
|||||||
|
|
||||||
Here is how you can define a signature:
|
Here is how you can define a signature:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=e
|
```pascaligo group=e
|
||||||
const my_sig : signature =
|
const my_sig : signature =
|
||||||
("edsigthTzJ8X7MPmNeEwybRAvdxS1pupqcM5Mk4uCuyZAe7uEk68YpuGDeViW8wSXMrCi5CwoNgqs8V2w8ayB5dMJzrYCHhD8C7" :
|
("edsigthTzJ8X7MPmNeEwybRAvdxS1pupqcM5Mk4uCuyZAe7uEk68YpuGDeViW8wSXMrCi5CwoNgqs8V2w8ayB5dMJzrYCHhD8C7" :
|
||||||
signature)
|
signature)
|
||||||
```
|
```
|
||||||
<!--CameLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=e
|
```cameligo group=e
|
||||||
let my_sig : signature =
|
let my_sig : signature =
|
||||||
("edsigthTzJ8X7MPmNeEwybRAvdxS1pupqcM5Mk4uCuyZAe7uEk68YpuGDeViW8wSXMrCi5CwoNgqs8V2w8ayB5dMJzrYCHhD8C7" :
|
("edsigthTzJ8X7MPmNeEwybRAvdxS1pupqcM5Mk4uCuyZAe7uEk68YpuGDeViW8wSXMrCi5CwoNgqs8V2w8ayB5dMJzrYCHhD8C7" :
|
||||||
signature)
|
signature)
|
||||||
```
|
```
|
||||||
<!--ReasonLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=e
|
```reasonligo group=e
|
||||||
let my_sig : signature =
|
let my_sig : signature =
|
||||||
("edsigthTzJ8X7MPmNeEwybRAvdxS1pupqcM5Mk4uCuyZAe7uEk68YpuGDeViW8wSXMrCi5CwoNgqs8V2w8ayB5dMJzrYCHhD8C7" :
|
("edsigthTzJ8X7MPmNeEwybRAvdxS1pupqcM5Mk4uCuyZAe7uEk68YpuGDeViW8wSXMrCi5CwoNgqs8V2w8ayB5dMJzrYCHhD8C7" :
|
||||||
signature);
|
signature);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Keys
|
## Keys
|
||||||
|
|
||||||
@ -213,20 +252,29 @@ failure if the key is invalid.
|
|||||||
|
|
||||||
Here is how you can define a key.
|
Here is how you can define a key.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=f
|
```pascaligo group=f
|
||||||
const my_key : key =
|
const my_key : key =
|
||||||
("edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav" : key)
|
("edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav" : key)
|
||||||
```
|
```
|
||||||
<!--CameLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=f
|
```cameligo group=f
|
||||||
let my_key : key =
|
let my_key : key =
|
||||||
("edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav" : key)
|
("edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav" : key)
|
||||||
```
|
```
|
||||||
<!--ReasonLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=f
|
```reasonligo group=f
|
||||||
let my_key : key =
|
let my_key : key =
|
||||||
("edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav" : key);
|
("edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav" : key);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
@ -2,14 +2,17 @@
|
|||||||
id: cheat-sheet
|
id: cheat-sheet
|
||||||
title: Cheat Sheet
|
title: Cheat Sheet
|
||||||
---
|
---
|
||||||
<div class="cheatsheet">
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
|
<div className="cheatsheet">
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Note that this table is not compiled before production and currently needs to be managed manually.
|
Note that this table is not compiled before production and currently needs to be managed manually.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
|Primitive |Example|
|
|Primitive |Example|
|
||||||
|--- |---|
|
|--- |---|
|
||||||
@ -33,7 +36,7 @@ Note that this table is not compiled before production and currently needs to be
|
|||||||
| If Statement | <pre><code>if age < 16 <br/>then failwith ("Too young to drive."); <br/>else const new_id: int = prev_id + 1;</code></pre>|
|
| If Statement | <pre><code>if age < 16 <br/>then failwith ("Too young to drive."); <br/>else const new_id: int = prev_id + 1;</code></pre>|
|
||||||
|Options|<pre><code>type middleName is option(string);<br/>const middleName : middleName = Some("Foo");<br/>const middleName : middleName = None;</code></pre>|
|
|Options|<pre><code>type middleName is option(string);<br/>const middleName : middleName = Some("Foo");<br/>const middleName : middleName = None;</code></pre>|
|
||||||
|Assignment| ```const age: int = 5;```|
|
|Assignment| ```const age: int = 5;```|
|
||||||
|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``` |
|
|Assignment on an existing variable <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``` |
|
||||||
|Type Annotations| ```("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address)```|
|
|Type Annotations| ```("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address)```|
|
||||||
|Variants|<pre><code>type action is<br/>| Increment of int<br/>| Decrement of int</code></pre>|
|
|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>|
|
||||||
@ -43,7 +46,8 @@ Note that this table is not compiled before production and currently needs to be
|
|||||||
|Transactions|<pre><code>const payment : operation = transaction(unit, amount, receiver);</code></pre>|
|
|Transactions|<pre><code>const payment : operation = transaction(unit, amount, receiver);</code></pre>|
|
||||||
|Exception/Failure|`failwith ("Your descriptive error message for the user goes here.")`|
|
|Exception/Failure|`failwith ("Your descriptive error message for the user goes here.")`|
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
|Primitive |Example|
|
|Primitive |Example|
|
||||||
|--- |---|
|
|--- |---|
|
||||||
@ -75,7 +79,8 @@ Note that this table is not compiled before production and currently needs to be
|
|||||||
|Transactions|<pre><code>let payment : operation = <br/> Tezos.transaction unit amount receiver</code></pre>|
|
|Transactions|<pre><code>let payment : operation = <br/> Tezos.transaction unit amount receiver</code></pre>|
|
||||||
|Exception/Failure|`failwith ("Your descriptive error message for the user goes here.")`|
|
|Exception/Failure|`failwith ("Your descriptive error message for the user goes here.")`|
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
|Primitive |Example|
|
|Primitive |Example|
|
||||||
|--- |---|
|
|--- |---|
|
||||||
@ -107,7 +112,8 @@ Note that this table is not compiled before production and currently needs to be
|
|||||||
|Transactions|<pre><code>let payment : operation = <br/> Tezos.transaction (unit, amount, receiver);</code></pre>|
|
|Transactions|<pre><code>let payment : operation = <br/> Tezos.transaction (unit, amount, receiver);</code></pre>|
|
||||||
|Exception/Failure|`failwith ("Your descriptive error message for the user goes here.");`|
|
|Exception/Failure|`failwith ("Your descriptive error message for the user goes here.");`|
|
||||||
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,6 +3,8 @@ id: what-and-why
|
|||||||
title: Michelson and LIGO
|
title: Michelson and LIGO
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
Before we get into what LIGO is and why LIGO needs to exist, let us
|
Before we get into what LIGO is and why LIGO needs to exist, let us
|
||||||
take a look at what options the Tezos blockchain offers us out of the
|
take a look at what options the Tezos blockchain offers us out of the
|
||||||
box. If you want to implement smart contracts natively on Tezos, you
|
box. If you want to implement smart contracts natively on Tezos, you
|
||||||
@ -161,8 +163,9 @@ Let us decline the same LIGO contract in the three flavours above. Do
|
|||||||
not worry if it is a little confusing at first; we will explain all
|
not worry if it is a little confusing at first; we will explain all
|
||||||
the syntax in the upcoming sections of the documentation.
|
the syntax in the upcoming sections of the documentation.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=a
|
```pascaligo group=a
|
||||||
type storage is int
|
type storage is int
|
||||||
|
|
||||||
@ -182,7 +185,9 @@ function main (const action : parameter; const store : storage) : return is
|
|||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=a
|
```cameligo group=a
|
||||||
type storage = int
|
type storage = int
|
||||||
|
|
||||||
@ -201,7 +206,9 @@ let main (action, store : parameter * storage) : return =
|
|||||||
| Reset -> 0)
|
| Reset -> 0)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=a
|
```reasonligo group=a
|
||||||
type storage = int;
|
type storage = int;
|
||||||
|
|
||||||
@ -220,7 +227,9 @@ let main = ((action, store): (parameter, storage)) : return => {
|
|||||||
| Reset => 0}));
|
| Reset => 0}));
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
@ -3,28 +3,39 @@ id: boolean-if-else
|
|||||||
title: Booleans and Conditionals
|
title: Booleans and Conditionals
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
## Booleans
|
## Booleans
|
||||||
|
|
||||||
The type of a boolean value is `bool`. Here is how to define a boolean
|
The type of a boolean value is `bool`. Here is how to define a boolean
|
||||||
value:
|
value:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=a
|
```pascaligo group=a
|
||||||
const a : bool = True // Also: true
|
const a : bool = True // Also: true
|
||||||
const b : bool = False // Also: false
|
const b : bool = False // Also: false
|
||||||
```
|
```
|
||||||
<!--CameLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=a
|
```cameligo group=a
|
||||||
let a : bool = true
|
let a : bool = true
|
||||||
let b : bool = false
|
let b : bool = false
|
||||||
```
|
```
|
||||||
<!--ReasonLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=a
|
```reasonligo group=a
|
||||||
let a : bool = true;
|
let a : bool = true;
|
||||||
let b : bool = false;
|
let b : bool = false;
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Comparing Values
|
## Comparing Values
|
||||||
|
|
||||||
@ -39,31 +50,41 @@ function.
|
|||||||
|
|
||||||
### Comparing Strings
|
### Comparing Strings
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=b
|
```pascaligo group=b
|
||||||
const a : string = "Alice"
|
const a : string = "Alice"
|
||||||
const b : string = "Alice"
|
const b : string = "Alice"
|
||||||
const c : bool = (a = b) // True
|
const c : bool = (a = b) // True
|
||||||
```
|
```
|
||||||
<!--CameLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=b
|
```cameligo group=b
|
||||||
let a : string = "Alice"
|
let a : string = "Alice"
|
||||||
let b : string = "Alice"
|
let b : string = "Alice"
|
||||||
let c : bool = (a = b) // true
|
let c : bool = (a = b) // true
|
||||||
```
|
```
|
||||||
<!--ReasonLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=b
|
```reasonligo group=b
|
||||||
let a : string = "Alice";
|
let a : string = "Alice";
|
||||||
let b : string = "Alice";
|
let b : string = "Alice";
|
||||||
let c : bool = (a == b); // true
|
let c : bool = (a == b); // true
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Comparing numbers
|
### Comparing numbers
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=c
|
```pascaligo group=c
|
||||||
const a : int = 5
|
const a : int = 5
|
||||||
const b : int = 4
|
const b : int = 4
|
||||||
@ -74,7 +95,10 @@ const f : bool = (a <= b)
|
|||||||
const g : bool = (a >= b)
|
const g : bool = (a >= b)
|
||||||
const h : bool = (a =/= b)
|
const h : bool = (a =/= b)
|
||||||
```
|
```
|
||||||
<!--CameLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=c
|
```cameligo group=c
|
||||||
let a : int = 5
|
let a : int = 5
|
||||||
let b : int = 4
|
let b : int = 4
|
||||||
@ -86,7 +110,9 @@ let g : bool = (a >= b)
|
|||||||
let h : bool = (a <> b)
|
let h : bool = (a <> b)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=c
|
```reasonligo group=c
|
||||||
let a : int = 5;
|
let a : int = 5;
|
||||||
let b : int = 4;
|
let b : int = 4;
|
||||||
@ -97,33 +123,43 @@ let f : bool = (a <= b);
|
|||||||
let g : bool = (a >= b);
|
let g : bool = (a >= b);
|
||||||
let h : bool = (a != b);
|
let h : bool = (a != b);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Comparing tez
|
### Comparing tez
|
||||||
|
|
||||||
> 💡 Comparing `tez` values is especially useful when dealing with an
|
> 💡 Comparing `tez` values is especially useful when dealing with an
|
||||||
> amount sent in a transaction.
|
> amount sent in a transaction.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=d
|
```pascaligo group=d
|
||||||
const a : tez = 5mutez
|
const a : tez = 5mutez
|
||||||
const b : tez = 10mutez
|
const b : tez = 10mutez
|
||||||
const c : bool = (a = b) // False
|
const c : bool = (a = b) // False
|
||||||
```
|
```
|
||||||
<!--CameLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=d
|
```cameligo group=d
|
||||||
let a : tez = 5mutez
|
let a : tez = 5mutez
|
||||||
let b : tez = 10mutez
|
let b : tez = 10mutez
|
||||||
let c : bool = (a = b) // false
|
let c : bool = (a = b) // false
|
||||||
```
|
```
|
||||||
<!--ReasonLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
```reasonligo group=d
|
```reasonligo group=d
|
||||||
let a : tez = 5mutez;
|
let a : tez = 5mutez;
|
||||||
let b : tez = 10mutez;
|
let b : tez = 10mutez;
|
||||||
let c : bool = (a == b); // false
|
let c : bool = (a == b); // false
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Conditionals
|
## Conditionals
|
||||||
@ -131,8 +167,9 @@ let c : bool = (a == b); // false
|
|||||||
Conditional logic enables forking the control flow depending on the
|
Conditional logic enables forking the control flow depending on the
|
||||||
state.
|
state.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=e
|
```pascaligo group=e
|
||||||
type magnitude is Small | Large // See variant types.
|
type magnitude is Small | Large // See variant types.
|
||||||
|
|
||||||
@ -171,7 +208,9 @@ if x < y then {
|
|||||||
else skip;
|
else skip;
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=e
|
```cameligo group=e
|
||||||
type magnitude = Small | Large // See variant types.
|
type magnitude = Small | Large // See variant types.
|
||||||
|
|
||||||
@ -192,8 +231,9 @@ gitlab-pages/docs/language-basics/boolean-if-else/cond.mligo compare 21n'
|
|||||||
> *dangling else* problem is parsed by associating any `else` to the
|
> *dangling else* problem is parsed by associating any `else` to the
|
||||||
> closest previous `then`.
|
> closest previous `then`.
|
||||||
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
|
||||||
```reasonligo group=e
|
```reasonligo group=e
|
||||||
type magnitude = Small | Large; // See variant types.
|
type magnitude = Small | Large; // See variant types.
|
||||||
|
|
||||||
@ -208,4 +248,6 @@ ligo run-function
|
|||||||
gitlab-pages/docs/language-basics/boolean-if-else/cond.religo compare 21n'
|
gitlab-pages/docs/language-basics/boolean-if-else/cond.religo compare 21n'
|
||||||
# Outputs: Large
|
# Outputs: Large
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ id: functions
|
|||||||
title: Functions
|
title: Functions
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
LIGO functions are the basic building block of contracts. For example,
|
LIGO functions are the basic building block of contracts. For example,
|
||||||
entrypoints are functions and each smart contract needs a main
|
entrypoints are functions and each smart contract needs a main
|
||||||
function that dispatches control to the entrypoints (it is not already
|
function that dispatches control to the entrypoints (it is not already
|
||||||
@ -16,8 +18,8 @@ mutations inside the functions will be.
|
|||||||
|
|
||||||
## Declaring Functions
|
## Declaring Functions
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
There are two ways in PascaLIGO to define functions: with or without a
|
There are two ways in PascaLIGO to define functions: with or without a
|
||||||
*block*.
|
*block*.
|
||||||
@ -91,7 +93,8 @@ ligo run-function gitlab-pages/docs/language-basics/src/functions/blockless.ligo
|
|||||||
# Outputs: 3
|
# Outputs: 3
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
Functions in CameLIGO are defined using the `let` keyword, like other
|
Functions in CameLIGO are defined using the `let` keyword, like other
|
||||||
values. The difference is that a succession of parameters is provided
|
values. The difference is that a succession of parameters is provided
|
||||||
@ -145,7 +148,8 @@ ligo run-function gitlab-pages/docs/language-basics/src/functions/curry.mligo in
|
|||||||
|
|
||||||
The function body is a single expression, whose value is returned.
|
The function body is a single expression, whose value is returned.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
Functions in ReasonLIGO are defined using the `let` keyword, like
|
Functions in ReasonLIGO are defined using the `let` keyword, like
|
||||||
other values. The difference is that a tuple of parameters is provided
|
other values. The difference is that a tuple of parameters is provided
|
||||||
@ -176,7 +180,8 @@ let myFun = ((x, y) : (int, int)) : int => {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Anonymous functions (a.k.a. lambdas)
|
## Anonymous functions (a.k.a. lambdas)
|
||||||
|
|
||||||
@ -186,8 +191,9 @@ a key in a record or a map.
|
|||||||
|
|
||||||
Here is how to define an anonymous function:
|
Here is how to define an anonymous function:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=c
|
```pascaligo group=c
|
||||||
function increment (const b : int) : int is
|
function increment (const b : int) : int is
|
||||||
(function (const a : int) : int is a + 1) (b)
|
(function (const a : int) : int is a + 1) (b)
|
||||||
@ -201,7 +207,9 @@ ligo evaluate-value gitlab-pages/docs/language-basics/src/functions/anon.ligo a
|
|||||||
# Outputs: 2
|
# Outputs: 2
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=c
|
```cameligo group=c
|
||||||
let increment (b : int) : int = (fun (a : int) -> a + 1) b
|
let increment (b : int) : int = (fun (a : int) -> a + 1) b
|
||||||
let a : int = increment 1 // a = 2
|
let a : int = increment 1 // a = 2
|
||||||
@ -214,7 +222,9 @@ ligo evaluate-value gitlab-pages/docs/language-basics/src/functions/anon.mligo a
|
|||||||
# Outputs: 2
|
# Outputs: 2
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=c
|
```reasonligo group=c
|
||||||
let increment = (b : int) : int => ((a : int) : int => a + 1) (b);
|
let increment = (b : int) : int => ((a : int) : int => a + 1) (b);
|
||||||
let a : int = increment (1); // a == 2
|
let a : int = increment (1); // a == 2
|
||||||
@ -227,15 +237,17 @@ ligo evaluate-value gitlab-pages/docs/language-basics/src/functions/anon.religo
|
|||||||
# Outputs: 2
|
# Outputs: 2
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
If the example above seems contrived, here is a more common design
|
If the example above seems contrived, here is a more common design
|
||||||
pattern for lambdas: to be used as parameters to functions. Consider
|
pattern for lambdas: to be used as parameters to functions. Consider
|
||||||
the use case of having a list of integers and mapping the increment
|
the use case of having a list of integers and mapping the increment
|
||||||
function to all its elements.
|
function to all its elements.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=c
|
```pascaligo group=c
|
||||||
function incr_map (const l : list (int)) : list (int) is
|
function incr_map (const l : list (int)) : list (int) is
|
||||||
List.map (function (const i : int) : int is i + 1, l)
|
List.map (function (const i : int) : int is i + 1, l)
|
||||||
@ -253,7 +265,9 @@ gitlab-pages/docs/language-basics/src/functions/incr_map.ligo incr_map
|
|||||||
# Outputs: [ 2 ; 3 ; 4 ]
|
# Outputs: [ 2 ; 3 ; 4 ]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=c
|
```cameligo group=c
|
||||||
let incr_map (l : int list) : int list =
|
let incr_map (l : int list) : int list =
|
||||||
List.map (fun (i : int) -> i + 1) l
|
List.map (fun (i : int) -> i + 1) l
|
||||||
@ -267,7 +281,9 @@ gitlab-pages/docs/language-basics/src/functions/incr_map.mligo incr_map
|
|||||||
# Outputs: [ 2 ; 3 ; 4 ]
|
# Outputs: [ 2 ; 3 ; 4 ]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=c
|
```reasonligo group=c
|
||||||
let incr_map = (l : list (int)) : list (int) =>
|
let incr_map = (l : list (int)) : list (int) =>
|
||||||
List.map ((i : int) => i + 1, l);
|
List.map ((i : int) => i + 1, l);
|
||||||
@ -281,4 +297,5 @@ gitlab-pages/docs/language-basics/src/functions/incr_map.religo incr_map
|
|||||||
# Outputs: [ 2 ; 3 ; 4 ]
|
# Outputs: [ 2 ; 3 ; 4 ]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,11 +3,13 @@ id: loops
|
|||||||
title: Loops
|
title: Loops
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
## General Iteration
|
## General Iteration
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
General iteration in PascaLIGO takes the shape of general loops, which
|
General iteration in PascaLIGO takes the shape of general loops, which
|
||||||
should be familiar to programmers of imperative languages as "while
|
should be familiar to programmers of imperative languages as "while
|
||||||
@ -47,7 +49,8 @@ gitlab-pages/docs/language-basics/src/loops/gcd.ligo gcd '(2n*2n*3n*11n, 2n*2n*2
|
|||||||
# Outputs: +12
|
# Outputs: +12
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
CameLIGO is a functional language where user-defined values are
|
CameLIGO is a functional language where user-defined values are
|
||||||
constant, therefore it makes no sense in CameLIGO to feature loops,
|
constant, therefore it makes no sense in CameLIGO to feature loops,
|
||||||
@ -103,7 +106,8 @@ gitlab-pages/docs/language-basics/src/loops/gcd.mligo gcd (2n*2n*3n*11n, 2n*2n*2
|
|||||||
# Outputs: +12
|
# Outputs: +12
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
ReasonLIGO is a functional language where user-defined values are
|
ReasonLIGO is a functional language where user-defined values are
|
||||||
constant, therefore it makes no sense in ReasonLIGO to feature loops,
|
constant, therefore it makes no sense in ReasonLIGO to feature loops,
|
||||||
@ -153,7 +157,8 @@ let gcd = ((x,y) : (nat, nat)) : nat => {
|
|||||||
> Note that `stop` and `continue` (now `Loop.resume`) are
|
> Note that `stop` and `continue` (now `Loop.resume`) are
|
||||||
> *deprecated*.
|
> *deprecated*.
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Bounded Loops
|
## Bounded Loops
|
||||||
|
|
||||||
@ -185,8 +190,8 @@ gitlab-pages/docs/language-basics/src/loops/sum.ligo sum 7n
|
|||||||
|
|
||||||
PascaLIGO "for" loops can also iterate through the contents of a
|
PascaLIGO "for" loops can also iterate through the contents of a
|
||||||
collection, that is, a list, a set or a map. This is done with a loop
|
collection, that is, a list, a set or a map. This is done with a loop
|
||||||
of the form `for <element var> in <collection type> <collection var>
|
of the form `for <element var> in <collection type> <collection var> <block>`,
|
||||||
<block>`, where `<collection type>` is any of the following keywords:
|
where `<collection type>` is any of the following keywords:
|
||||||
`list`, `set` or `map`.
|
`list`, `set` or `map`.
|
||||||
|
|
||||||
Here is an example where the integers in a list are summed up.
|
Here is an example where the integers in a list are summed up.
|
||||||
|
@ -3,6 +3,8 @@ id: maps-records
|
|||||||
title: Records and Maps
|
title: Records and Maps
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
So far we have seen pretty basic data types. LIGO also offers more
|
So far we have seen pretty basic data types. LIGO also offers more
|
||||||
complex built-in constructs, such as *records* and *maps*.
|
complex built-in constructs, such as *records* and *maps*.
|
||||||
|
|
||||||
@ -16,9 +18,10 @@ special operator (`.`).
|
|||||||
|
|
||||||
Let us first consider and example of record type declaration.
|
Let us first consider and example of record type declaration.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=records1
|
```pascaligo group=records1
|
||||||
type user is
|
type user is
|
||||||
record [
|
record [
|
||||||
@ -28,7 +31,9 @@ type user is
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=records1
|
```cameligo group=records1
|
||||||
type user = {
|
type user = {
|
||||||
id : nat;
|
id : nat;
|
||||||
@ -37,7 +42,9 @@ type user = {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=records1
|
```reasonligo group=records1
|
||||||
type user = {
|
type user = {
|
||||||
id : nat,
|
id : nat,
|
||||||
@ -45,12 +52,15 @@ type user = {
|
|||||||
name : string
|
name : string
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
And here is how a record value is defined:
|
And here is how a record value is defined:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=records1
|
```pascaligo group=records1
|
||||||
const alice : user =
|
const alice : user =
|
||||||
record [
|
record [
|
||||||
@ -60,7 +70,9 @@ const alice : user =
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=records1
|
```cameligo group=records1
|
||||||
let alice : user = {
|
let alice : user = {
|
||||||
id = 1n;
|
id = 1n;
|
||||||
@ -69,7 +81,9 @@ let alice : user = {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=records1
|
```reasonligo group=records1
|
||||||
let alice : user = {
|
let alice : user = {
|
||||||
id : 1n,
|
id : 1n,
|
||||||
@ -77,29 +91,38 @@ let alice : user = {
|
|||||||
name : "Alice"
|
name : "Alice"
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Accessing Record Fields
|
### Accessing Record Fields
|
||||||
|
|
||||||
If we want the contents of a given field, we use the (`.`) infix
|
If we want the contents of a given field, we use the (`.`) infix
|
||||||
operator, like so:
|
operator, like so:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=records1
|
```pascaligo group=records1
|
||||||
const alice_admin : bool = alice.is_admin
|
const alice_admin : bool = alice.is_admin
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=records1
|
```cameligo group=records1
|
||||||
let alice_admin : bool = alice.is_admin
|
let alice_admin : bool = alice.is_admin
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=records1
|
```reasonligo group=records1
|
||||||
let alice_admin : bool = alice.is_admin;
|
let alice_admin : bool = alice.is_admin;
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Functional Updates
|
### Functional Updates
|
||||||
|
|
||||||
@ -115,12 +138,13 @@ updated record.
|
|||||||
Let us consider defining a function that translates three-dimensional
|
Let us consider defining a function that translates three-dimensional
|
||||||
points on a plane.
|
points on a plane.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
|
||||||
In PascaLIGO, the shape of that expression is `<record variable> with
|
<Syntax syntax="pascaligo">
|
||||||
<record value>`. The record variable is the record to update and the
|
|
||||||
|
In PascaLIGO, the shape of that expression is
|
||||||
|
`<record variable> with <record value>`.
|
||||||
|
The record variable is the record to update and the
|
||||||
record value is the update itself.
|
record value is the update itself.
|
||||||
|
|
||||||
```pascaligo group=records2
|
```pascaligo group=records2
|
||||||
@ -146,7 +170,8 @@ You have to understand that `p` has not been changed by the functional
|
|||||||
update: a namless new version of it has been created and returned by
|
update: a namless new version of it has been created and returned by
|
||||||
the blockless function.
|
the blockless function.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
The syntax for the functional updates of record in CameLIGO follows
|
The syntax for the functional updates of record in CameLIGO follows
|
||||||
that of OCaml:
|
that of OCaml:
|
||||||
@ -174,7 +199,8 @@ xy_translate "({x=2;y=3;z=1}, {dx=3;dy=4})"
|
|||||||
> functional update: a nameless new version of it has been created and
|
> functional update: a nameless new version of it has been created and
|
||||||
> returned.
|
> returned.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
The syntax for the functional updates of record in ReasonLIGO follows
|
The syntax for the functional updates of record in ReasonLIGO follows
|
||||||
that of ReasonML:
|
that of ReasonML:
|
||||||
@ -188,7 +214,9 @@ let origin : point = {x : 0, y : 0, z : 0};
|
|||||||
let xy_translate = ((p, vec) : (point, vector)) : point =>
|
let xy_translate = ((p, vec) : (point, vector)) : point =>
|
||||||
{...p, x : p.x + vec.dx, y : p.y + vec.dy};
|
{...p, x : p.x + vec.dx, y : p.y + vec.dy};
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
You can call the function `xy_translate` defined above by running the
|
You can call the function `xy_translate` defined above by running the
|
||||||
following command of the shell:
|
following command of the shell:
|
||||||
@ -303,55 +331,69 @@ sense.
|
|||||||
Here is how a custom map from addresses to a pair of integers is
|
Here is how a custom map from addresses to a pair of integers is
|
||||||
defined.
|
defined.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
type move is int * int
|
type move is int * int
|
||||||
type register is map (address, move)
|
type register is map (address, move)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
type move = int * int
|
type move = int * int
|
||||||
type register = (address, move) map
|
type register = (address, move) map
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
type move = (int, int);
|
type move = (int, int);
|
||||||
type register = map (address, move);
|
type register = map (address, move);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Creating an Empty Map
|
### Creating an Empty Map
|
||||||
|
|
||||||
Here is how to create an empty map.
|
Here is how to create an empty map.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
const empty : register = map []
|
const empty : register = map []
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
let empty : register = Map.empty
|
let empty : register = Map.empty
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
let empty : register = Map.empty
|
let empty : register = Map.empty
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Creating a Non-empty Map
|
### Creating a Non-empty Map
|
||||||
|
|
||||||
And here is how to create a non-empty map value:
|
And here is how to create a non-empty map value:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
const moves : register =
|
const moves : register =
|
||||||
@ -365,7 +407,9 @@ individual map entries. The annotated value `("<string value>" :
|
|||||||
address)` means that we cast a string into an address. Also, `map` is
|
address)` means that we cast a string into an address. Also, `map` is
|
||||||
a keyword.
|
a keyword.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
let moves : register =
|
let moves : register =
|
||||||
Map.literal [
|
Map.literal [
|
||||||
@ -378,7 +422,9 @@ key-value pair tuples, `(<key>, <value>)`. Note also the `;` to
|
|||||||
separate individual map entries. `("<string value>": address)` means
|
separate individual map entries. `("<string value>": address)` means
|
||||||
that we type-cast a string into an address. -->
|
that we type-cast a string into an address. -->
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
let moves : register =
|
let moves : register =
|
||||||
Map.literal ([
|
Map.literal ([
|
||||||
@ -391,12 +437,13 @@ key-value pair tuples, `(<key>, <value>)`. Note also the `;` to
|
|||||||
separate individual map entries. `("<string value>": address)` means
|
separate individual map entries. `("<string value>": address)` means
|
||||||
that we type-cast a string into an address. -->
|
that we type-cast a string into an address. -->
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Accessing Map Bindings
|
### Accessing Map Bindings
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
In PascaLIGO, we can use the postfix `[]` operator to read the `move`
|
In PascaLIGO, we can use the postfix `[]` operator to read the `move`
|
||||||
value associated to a given key (`address` here) in the register. Here
|
value associated to a given key (`address` here) in the register. Here
|
||||||
@ -407,26 +454,33 @@ const my_balance : option (move) =
|
|||||||
moves [("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address)]
|
moves [("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address)]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
let my_balance : move option =
|
let my_balance : move option =
|
||||||
Map.find_opt ("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) moves
|
Map.find_opt ("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) moves
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
let my_balance : option (move) =
|
let my_balance : option (move) =
|
||||||
Map.find_opt (("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address), moves);
|
Map.find_opt (("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address), moves);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
Notice how the value we read is an optional value: this is to force
|
Notice how the value we read is an optional value: this is to force
|
||||||
the reader to account for a missing key in the map. This requires
|
the reader to account for a missing key in the map. This requires
|
||||||
*pattern matching*.
|
*pattern matching*.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
function force_access (const key : address; const moves : register) : move is
|
function force_access (const key : address; const moves : register) : move is
|
||||||
case moves[key] of
|
case moves[key] of
|
||||||
@ -435,7 +489,9 @@ function force_access (const key : address; const moves : register) : move is
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
let force_access (key, moves : address * register) : move =
|
let force_access (key, moves : address * register) : move =
|
||||||
match Map.find_opt key moves with
|
match Map.find_opt key moves with
|
||||||
@ -443,7 +499,9 @@ let force_access (key, moves : address * register) : move =
|
|||||||
| None -> (failwith "No move." : move)
|
| None -> (failwith "No move." : move)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
let force_access = ((key, moves) : (address, register)) : move => {
|
let force_access = ((key, moves) : (address, register)) : move => {
|
||||||
switch (Map.find_opt (key, moves)) {
|
switch (Map.find_opt (key, moves)) {
|
||||||
@ -452,7 +510,9 @@ let force_access = ((key, moves) : (address, register)) : move => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Updating a Map
|
### Updating a Map
|
||||||
@ -461,9 +521,9 @@ Given a map, we may want to add a new binding, remove one, or modify
|
|||||||
one by changing the value associated to an already existing key. All
|
one by changing the value associated to an already existing key. All
|
||||||
those operations are called *updates*.
|
those operations are called *updates*.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
The values of a PascaLIGO map can be updated using the usual
|
The values of a PascaLIGO map can be updated using the usual
|
||||||
assignment syntax `<map variable>[<key>] := <new value>`. Let us
|
assignment syntax `<map variable>[<key>] := <new value>`. Let us
|
||||||
@ -491,7 +551,8 @@ function assignments (var m : register) : register is
|
|||||||
|
|
||||||
See further for the removal of bindings.
|
See further for the removal of bindings.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
We can update a binding in a map in CameLIGO by means of the
|
We can update a binding in a map in CameLIGO by means of the
|
||||||
`Map.update` built-in function:
|
`Map.update` built-in function:
|
||||||
@ -513,7 +574,8 @@ let add (m : register) : register =
|
|||||||
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) (4,9) m
|
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) (4,9) m
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
We can update a binding in a map in ReasonLIGO by means of the
|
We can update a binding in a map in ReasonLIGO by means of the
|
||||||
`Map.update` built-in function:
|
`Map.update` built-in function:
|
||||||
@ -535,13 +597,14 @@ let add = (m : register) : register =>
|
|||||||
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address), (4,9), m);
|
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address), (4,9), m);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
To remove a binding from a map, we need its key.
|
To remove a binding from a map, we need its key.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
In PascaLIGO, there is a special instruction to remove a binding from
|
In PascaLIGO, there is a special instruction to remove a binding from
|
||||||
a map.
|
a map.
|
||||||
@ -552,7 +615,8 @@ function delete (const key : address; var moves : register) : register is
|
|||||||
} with moves
|
} with moves
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
In CameLIGO, we use the predefined function `Map.remove` as follows:
|
In CameLIGO, we use the predefined function `Map.remove` as follows:
|
||||||
|
|
||||||
@ -561,7 +625,8 @@ let delete (key, moves : address * register) : register =
|
|||||||
Map.remove key moves
|
Map.remove key moves
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
In ReasonLIGO, we use the predefined function `Map.remove` as follows:
|
In ReasonLIGO, we use the predefined function `Map.remove` as follows:
|
||||||
|
|
||||||
@ -570,7 +635,8 @@ let delete = ((key, moves) : (address, register)) : register =>
|
|||||||
Map.remove (key, moves);
|
Map.remove (key, moves);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Functional Iteration over Maps
|
### Functional Iteration over Maps
|
||||||
@ -596,9 +662,9 @@ over maps is called `Map.iter`. In the following example, the register
|
|||||||
of moves is iterated to check that the start of each move is above
|
of moves is iterated to check that the start of each move is above
|
||||||
`3`.
|
`3`.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
function iter_op (const m : register) : unit is
|
function iter_op (const m : register) : unit is
|
||||||
@ -610,7 +676,8 @@ function iter_op (const m : register) : unit is
|
|||||||
|
|
||||||
> Note that `map_iter` is *deprecated*.
|
> Note that `map_iter` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
let iter_op (m : register) : unit =
|
let iter_op (m : register) : unit =
|
||||||
@ -618,7 +685,8 @@ let iter_op (m : register) : unit =
|
|||||||
in Map.iter predicate m
|
in Map.iter predicate m
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
let iter_op = (m : register) : unit => {
|
let iter_op = (m : register) : unit => {
|
||||||
@ -626,7 +694,9 @@ let iter_op = (m : register) : unit => {
|
|||||||
Map.iter (predicate, m);
|
Map.iter (predicate, m);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
#### Map Operations over Maps
|
#### Map Operations over Maps
|
||||||
|
|
||||||
@ -637,9 +707,9 @@ implementing the map operation over maps is called `Map.map`. In the
|
|||||||
following example, we add `1` to the ordinate of the moves in the
|
following example, we add `1` to the ordinate of the moves in the
|
||||||
register.
|
register.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
function map_op (const m : register) : register is
|
function map_op (const m : register) : register is
|
||||||
@ -651,7 +721,8 @@ function map_op (const m : register) : register is
|
|||||||
|
|
||||||
> Note that `map_map` is *deprecated*.
|
> Note that `map_map` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
let map_op (m : register) : register =
|
let map_op (m : register) : register =
|
||||||
@ -659,7 +730,8 @@ let map_op (m : register) : register =
|
|||||||
in Map.map increment m
|
in Map.map increment m
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
let map_op = (m : register) : register => {
|
let map_op = (m : register) : register => {
|
||||||
@ -667,7 +739,9 @@ let map_op = (m : register) : register => {
|
|||||||
Map.map (increment, m);
|
Map.map (increment, m);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
#### Folded Operations over Maps
|
#### Folded Operations over Maps
|
||||||
|
|
||||||
@ -680,9 +754,9 @@ traversal of the data structure is over.
|
|||||||
The predefined functional iterator implementing the folded operation
|
The predefined functional iterator implementing the folded operation
|
||||||
over maps is called `Map.fold` and is used as follows.
|
over maps is called `Map.fold` and is used as follows.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
function fold_op (const m : register) : int is
|
function fold_op (const m : register) : int is
|
||||||
@ -694,7 +768,8 @@ function fold_op (const m : register) : int is
|
|||||||
|
|
||||||
> Note that `map_fold` is *deprecated*.
|
> Note that `map_fold` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
let fold_op (m : register) : register =
|
let fold_op (m : register) : register =
|
||||||
@ -702,7 +777,8 @@ let fold_op (m : register) : register =
|
|||||||
in Map.fold folded m 5
|
in Map.fold folded m 5
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
let fold_op = (m : register) : register => {
|
let fold_op = (m : register) : register => {
|
||||||
@ -711,7 +787,8 @@ let fold_op = (m : register) : register => {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Big Maps
|
## Big Maps
|
||||||
|
|
||||||
@ -728,55 +805,69 @@ interface for big maps is analogous to the one used for ordinary maps.
|
|||||||
|
|
||||||
Here is how we define a big map:
|
Here is how we define a big map:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=big_maps
|
```pascaligo group=big_maps
|
||||||
type move is int * int
|
type move is int * int
|
||||||
type register is big_map (address, move)
|
type register is big_map (address, move)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=big_maps
|
```cameligo group=big_maps
|
||||||
type move = int * int
|
type move = int * int
|
||||||
type register = (address, move) big_map
|
type register = (address, move) big_map
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=big_maps
|
```reasonligo group=big_maps
|
||||||
type move = (int, int);
|
type move = (int, int);
|
||||||
type register = big_map (address, move);
|
type register = big_map (address, move);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Creating an Empty Big Map
|
### Creating an Empty Big Map
|
||||||
|
|
||||||
Here is how to create an empty big map.
|
Here is how to create an empty big map.
|
||||||
|
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=big_maps
|
```pascaligo group=big_maps
|
||||||
const empty : register = big_map []
|
const empty : register = big_map []
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=big_maps
|
```cameligo group=big_maps
|
||||||
let empty : register = Big_map.empty
|
let empty : register = Big_map.empty
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=big_maps
|
```reasonligo group=big_maps
|
||||||
let empty : register = Big_map.empty
|
let empty : register = Big_map.empty
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Creating a Non-empty Map
|
### Creating a Non-empty Map
|
||||||
|
|
||||||
And here is how to create a non-empty map value:
|
And here is how to create a non-empty map value:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=big_maps
|
```pascaligo group=big_maps
|
||||||
const moves : register =
|
const moves : register =
|
||||||
@ -790,7 +881,8 @@ semicolon separating individual map entries. The value annotation
|
|||||||
`("<string value>" : address)` means that we cast a string into an
|
`("<string value>" : address)` means that we cast a string into an
|
||||||
address. -->
|
address. -->
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=big_maps
|
```cameligo group=big_maps
|
||||||
let moves : register =
|
let moves : register =
|
||||||
@ -804,7 +896,8 @@ list of key-value pairs `(<key>, <value>)`. Note also the semicolon
|
|||||||
separating individual map entries. The annotated value `("<string>
|
separating individual map entries. The annotated value `("<string>
|
||||||
value>" : address)` means that we cast a string into an address.
|
value>" : address)` means that we cast a string into an address.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=big_maps
|
```reasonligo group=big_maps
|
||||||
let moves : register =
|
let moves : register =
|
||||||
@ -818,8 +911,8 @@ list of key-value pairs `(<key>, <value>)`. Note also the semicolon
|
|||||||
separating individual map entries. The annotated value `("<string>
|
separating individual map entries. The annotated value `("<string>
|
||||||
value>" : address)` means that we cast a string into an address.
|
value>" : address)` means that we cast a string into an address.
|
||||||
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
### Accessing Values
|
### Accessing Values
|
||||||
|
|
||||||
@ -828,35 +921,39 @@ postfix `[]` operator to read the associated `move` value. However,
|
|||||||
the value we read is an optional value (in our case, of type `option
|
the value we read is an optional value (in our case, of type `option
|
||||||
(move)`), to account for a missing key. Here is an example:
|
(move)`), to account for a missing key. Here is an example:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=big_maps
|
```pascaligo group=big_maps
|
||||||
const my_balance : option (move) =
|
const my_balance : option (move) =
|
||||||
moves [("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address)]
|
moves [("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address)]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=big_maps
|
```cameligo group=big_maps
|
||||||
let my_balance : move option =
|
let my_balance : move option =
|
||||||
Big_map.find_opt ("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) moves
|
Big_map.find_opt ("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) moves
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=big_maps
|
```reasonligo group=big_maps
|
||||||
let my_balance : option (move) =
|
let my_balance : option (move) =
|
||||||
Big_map.find_opt ("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address, moves);
|
Big_map.find_opt ("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address, moves);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Updating Big Maps
|
### Updating Big Maps
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
The values of a PascaLIGO big map can be updated using the
|
The values of a PascaLIGO big map can be updated using the
|
||||||
assignment syntax for ordinary maps
|
assignment syntax for ordinary maps
|
||||||
@ -870,7 +967,8 @@ function add (var m : register) : register is
|
|||||||
const updated_map : register = add (moves)
|
const updated_map : register = add (moves)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
We can update a big map in CameLIGO using the `Big_map.update`
|
We can update a big map in CameLIGO using the `Big_map.update`
|
||||||
built-in:
|
built-in:
|
||||||
@ -881,7 +979,8 @@ let updated_map : register =
|
|||||||
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) (Some (4,9)) moves
|
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) (Some (4,9)) moves
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
We can update a big map in ReasonLIGO using the `Big_map.update`
|
We can update a big map in ReasonLIGO using the `Big_map.update`
|
||||||
built-in:
|
built-in:
|
||||||
@ -892,16 +991,17 @@ let updated_map : register =
|
|||||||
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN": address), Some ((4,9)), moves);
|
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN": address), Some ((4,9)), moves);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Removing Bindings
|
### Removing Bindings
|
||||||
|
|
||||||
Removing a binding in a map is done differently according to the LIGO
|
Removing a binding in a map is done differently according to the LIGO
|
||||||
syntax.
|
syntax.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
PascaLIGO features a special syntactic construct to remove bindings
|
PascaLIGO features a special syntactic construct to remove bindings
|
||||||
from maps, of the form `remove <key> from map <map>`. For example,
|
from maps, of the form `remove <key> from map <map>`. For example,
|
||||||
@ -915,7 +1015,8 @@ function rem (var m : register) : register is
|
|||||||
const updated_map : register = rem (moves)
|
const updated_map : register = rem (moves)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
In CameLIGO, the predefined function which removes a binding in a map
|
In CameLIGO, the predefined function which removes a binding in a map
|
||||||
is called `Map.remove` and is used as follows:
|
is called `Map.remove` and is used as follows:
|
||||||
@ -925,7 +1026,8 @@ let updated_map : register =
|
|||||||
Map.remove ("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN": address) moves
|
Map.remove ("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN": address) moves
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
In ReasonLIGO, the predefined function which removes a binding in a map
|
In ReasonLIGO, the predefined function which removes a binding in a map
|
||||||
is called `Map.remove` and is used as follows:
|
is called `Map.remove` and is used as follows:
|
||||||
@ -935,4 +1037,5 @@ let updated_map : register =
|
|||||||
Map.remove (("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN": address), moves)
|
Map.remove (("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN": address), moves)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ id: math-numbers-tez
|
|||||||
title: Math, Numbers & Tez
|
title: Math, Numbers & Tez
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
LIGO offers three built-in numerical types: `int`, `nat` and
|
LIGO offers three built-in numerical types: `int`, `nat` and
|
||||||
`tez`. Values of type `int` are integers; values of type `nat` are
|
`tez`. Values of type `int` are integers; values of type `nat` are
|
||||||
natural numbers (integral numbers greater than or equal to zero);
|
natural numbers (integral numbers greater than or equal to zero);
|
||||||
@ -38,8 +40,9 @@ remain in comments as they would otherwise not compile, for example,
|
|||||||
adding a value of type `int` to a value of type `tez` is invalid. Note
|
adding a value of type `int` to a value of type `tez` is invalid. Note
|
||||||
that adding an integer to a natural number produces an integer.
|
that adding an integer to a natural number produces an integer.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=a
|
```pascaligo group=a
|
||||||
// int + int yields int
|
// int + int yields int
|
||||||
const a : int = 5 + 10
|
const a : int = 5 + 10
|
||||||
@ -69,7 +72,9 @@ const g : int = 1_000_000
|
|||||||
> const sum : tez = 100_000mutez
|
> const sum : tez = 100_000mutez
|
||||||
>```
|
>```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=a
|
```cameligo group=a
|
||||||
// int + int yields int
|
// int + int yields int
|
||||||
let a : int = 5 + 10
|
let a : int = 5 + 10
|
||||||
@ -99,7 +104,9 @@ let g : int = 1_000_000
|
|||||||
>let sum : tez = 100_000mutez
|
>let sum : tez = 100_000mutez
|
||||||
>```
|
>```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=a
|
```reasonligo group=a
|
||||||
// int + int yields int
|
// int + int yields int
|
||||||
let a : int = 5 + 10;
|
let a : int = 5 + 10;
|
||||||
@ -127,7 +134,9 @@ let g : int = 1_000_000;
|
|||||||
>```reasonligo
|
>```reasonligo
|
||||||
>let sum : tex = 100_000mutez;
|
>let sum : tex = 100_000mutez;
|
||||||
>```
|
>```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Subtraction
|
## Subtraction
|
||||||
|
|
||||||
@ -135,8 +144,9 @@ Subtraction looks as follows.
|
|||||||
|
|
||||||
> ⚠️ Even when subtracting two `nats`, the result is an `int`
|
> ⚠️ Even when subtracting two `nats`, the result is an `int`
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=b
|
```pascaligo group=b
|
||||||
const a : int = 5 - 10
|
const a : int = 5 - 10
|
||||||
|
|
||||||
@ -149,7 +159,9 @@ const b : int = 5n - 2n
|
|||||||
const d : tez = 5mutez - 1mutez
|
const d : tez = 5mutez - 1mutez
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=b
|
```cameligo group=b
|
||||||
let a : int = 5 - 10
|
let a : int = 5 - 10
|
||||||
|
|
||||||
@ -162,7 +174,9 @@ let b : int = 5n - 2n
|
|||||||
let d : tez = 5mutez - 1mutez
|
let d : tez = 5mutez - 1mutez
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=b
|
```reasonligo group=b
|
||||||
let a : int = 5 - 10;
|
let a : int = 5 - 10;
|
||||||
|
|
||||||
@ -175,15 +189,16 @@ let b : int = 5n - 2n;
|
|||||||
let d : tez = 5mutez - 1mutez;
|
let d : tez = 5mutez - 1mutez;
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Multiplication
|
## Multiplication
|
||||||
|
|
||||||
You can multiply values of the same type, such as:
|
You can multiply values of the same type, such as:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=c
|
```pascaligo group=c
|
||||||
const a : int = 5 * 5
|
const a : int = 5 * 5
|
||||||
@ -193,7 +208,9 @@ const b : nat = 5n * 5n
|
|||||||
const c : tez = 5n * 5mutez
|
const c : tez = 5n * 5mutez
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=c
|
```cameligo group=c
|
||||||
let a : int = 5 * 5
|
let a : int = 5 * 5
|
||||||
let b : nat = 5n * 5n
|
let b : nat = 5n * 5n
|
||||||
@ -202,7 +219,9 @@ let b : nat = 5n * 5n
|
|||||||
let c : tez = 5n * 5mutez
|
let c : tez = 5n * 5mutez
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=c
|
```reasonligo group=c
|
||||||
let a : int = 5 * 5;
|
let a : int = 5 * 5;
|
||||||
let b : nat = 5n * 5n;
|
let b : nat = 5n * 5n;
|
||||||
@ -211,7 +230,8 @@ let b : nat = 5n * 5n;
|
|||||||
let c : tez = 5n * 5mutez;
|
let c : tez = 5n * 5mutez;
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Euclidean Division
|
## Euclidean Division
|
||||||
|
|
||||||
@ -219,35 +239,42 @@ In LIGO you can divide `int`, `nat`, and `tez`. Here is how:
|
|||||||
|
|
||||||
> ⚠️ Division of two `tez` values results into a `nat`
|
> ⚠️ Division of two `tez` values results into a `nat`
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=d
|
```pascaligo group=d
|
||||||
const a : int = 10 / 3
|
const a : int = 10 / 3
|
||||||
const b : nat = 10n / 3n
|
const b : nat = 10n / 3n
|
||||||
const c : nat = 10mutez / 3mutez
|
const c : nat = 10mutez / 3mutez
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=d
|
```cameligo group=d
|
||||||
let a : int = 10 / 3
|
let a : int = 10 / 3
|
||||||
let b : nat = 10n / 3n
|
let b : nat = 10n / 3n
|
||||||
let c : nat = 10mutez / 3mutez
|
let c : nat = 10mutez / 3mutez
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=d
|
```reasonligo group=d
|
||||||
let a : int = 10 / 3;
|
let a : int = 10 / 3;
|
||||||
let b : nat = 10n / 3n;
|
let b : nat = 10n / 3n;
|
||||||
let c : nat = 10mutez / 3mutez;
|
let c : nat = 10mutez / 3mutez;
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
LIGO also allows you to compute the remainder of the Euclidean
|
LIGO also allows you to compute the remainder of the Euclidean
|
||||||
division. In LIGO, it is a natural number.
|
division. In LIGO, it is a natural number.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=d
|
```pascaligo group=d
|
||||||
const a : int = 120
|
const a : int = 120
|
||||||
const b : int = 9
|
const b : int = 9
|
||||||
@ -259,7 +286,9 @@ const rem3 : nat = c mod d // 3
|
|||||||
const rem4 : nat = a mod d // 3
|
const rem4 : nat = a mod d // 3
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=d
|
```cameligo group=d
|
||||||
let a : int = 120
|
let a : int = 120
|
||||||
let b : int = 9
|
let b : int = 9
|
||||||
@ -271,7 +300,9 @@ let rem3 : nat = c mod d // 3
|
|||||||
let rem4 : nat = a mod d // 3
|
let rem4 : nat = a mod d // 3
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=d
|
```reasonligo group=d
|
||||||
let a : int = 120;
|
let a : int = 120;
|
||||||
let b : int = 9;
|
let b : int = 9;
|
||||||
@ -283,29 +314,39 @@ let rem3 : nat = c mod d; // 3
|
|||||||
let rem4 : nat = a mod d; // 3
|
let rem4 : nat = a mod d; // 3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## From `int` to `nat` and back
|
## From `int` to `nat` and back
|
||||||
|
|
||||||
You can *cast* an `int` to a `nat` and vice versa. Here is how:
|
You can *cast* an `int` to a `nat` and vice versa. Here is how:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=e
|
```pascaligo group=e
|
||||||
const a : int = int (1n)
|
const a : int = int (1n)
|
||||||
const b : nat = abs (1)
|
const b : nat = abs (1)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=e
|
```cameligo group=e
|
||||||
let a : int = int (1n)
|
let a : int = int (1n)
|
||||||
let b : nat = abs (1)
|
let b : nat = abs (1)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=e
|
```reasonligo group=e
|
||||||
let a : int = int (1n);
|
let a : int = int (1n);
|
||||||
let b : nat = abs (1);
|
let b : nat = abs (1);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Checking a `nat`
|
## Checking a `nat`
|
||||||
|
|
||||||
@ -314,20 +355,26 @@ function which accepts an `int` and returns an optional `nat`: if the
|
|||||||
result is not `None`, then the provided integer was indeed a natural
|
result is not `None`, then the provided integer was indeed a natural
|
||||||
number, and not otherwise.
|
number, and not otherwise.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=e
|
```pascaligo group=e
|
||||||
const is_a_nat : option (nat) = is_nat (1)
|
const is_a_nat : option (nat) = is_nat (1)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=e
|
```cameligo group=e
|
||||||
let is_a_nat : nat option = Michelson.is_nat (1)
|
let is_a_nat : nat option = Michelson.is_nat (1)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=e
|
```reasonligo group=e
|
||||||
let is_a_nat : option (nat) = Michelson.is_nat (1);
|
let is_a_nat : option (nat) = Michelson.is_nat (1);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ id: sets-lists-tuples
|
|||||||
title: Tuples, Lists, Sets
|
title: Tuples, Lists, Sets
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
Apart from complex data types such as `maps` and `records`, LIGO also
|
Apart from complex data types such as `maps` and `records`, LIGO also
|
||||||
features `tuples`, `lists` and `sets`.
|
features `tuples`, `lists` and `sets`.
|
||||||
|
|
||||||
@ -27,9 +29,9 @@ Unlike [a record](language-basics/maps-records.md), tuple types do not
|
|||||||
have to be defined before they can be used. However below we will give
|
have to be defined before they can be used. However below we will give
|
||||||
them names by *type aliasing*.
|
them names by *type aliasing*.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--Pascaligo-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=tuple
|
```pascaligo group=tuple
|
||||||
type full_name is string * string // Alias
|
type full_name is string * string // Alias
|
||||||
@ -37,7 +39,8 @@ type full_name is string * string // Alias
|
|||||||
const full_name : full_name = ("Alice", "Johnson")
|
const full_name : full_name = ("Alice", "Johnson")
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=tuple
|
```cameligo group=tuple
|
||||||
type full_name = string * string // Alias
|
type full_name = string * string // Alias
|
||||||
@ -45,7 +48,8 @@ type full_name = string * string // Alias
|
|||||||
let full_name : full_name = ("Alice", "Johnson") // Optional parentheses
|
let full_name : full_name = ("Alice", "Johnson") // Optional parentheses
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=tuple
|
```reasonligo group=tuple
|
||||||
type full_name = (string, string); // Alias
|
type full_name = (string, string); // Alias
|
||||||
@ -53,7 +57,8 @@ type full_name = (string, string); // Alias
|
|||||||
let full_name : full_name = ("Alice", "Johnson");
|
let full_name : full_name = ("Alice", "Johnson");
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Accessing Components
|
### Accessing Components
|
||||||
@ -66,27 +71,30 @@ position in their tuple, which cannot be done in OCaml. *Tuple
|
|||||||
components are zero-indexed*, that is, the first component has index
|
components are zero-indexed*, that is, the first component has index
|
||||||
`0`.
|
`0`.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=tuple
|
```pascaligo group=tuple
|
||||||
const first_name : string = full_name.0
|
const first_name : string = full_name.0
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=tuple
|
```cameligo group=tuple
|
||||||
let first_name : string = full_name.0
|
let first_name : string = full_name.0
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=tuple
|
```reasonligo group=tuple
|
||||||
let first_name : string = full_name[0];
|
let first_name : string = full_name[0];
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Lists
|
## Lists
|
||||||
|
|
||||||
@ -103,26 +111,32 @@ think of a list a *stack*, where the top is written on the left.
|
|||||||
|
|
||||||
### Defining Lists
|
### Defining Lists
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=lists
|
```pascaligo group=lists
|
||||||
const empty_list : list (int) = nil // Or list []
|
const empty_list : list (int) = nil // Or list []
|
||||||
const my_list : list (int) = list [1; 2; 2] // The head is 1
|
const my_list : list (int) = list [1; 2; 2] // The head is 1
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=lists
|
```cameligo group=lists
|
||||||
let empty_list : int list = []
|
let empty_list : int list = []
|
||||||
let my_list : int list = [1; 2; 2] // The head is 1
|
let my_list : int list = [1; 2; 2] // The head is 1
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=lists
|
```reasonligo group=lists
|
||||||
let empty_list : list (int) = [];
|
let empty_list : list (int) = [];
|
||||||
let my_list : list (int) = [1, 2, 2]; // The head is 1
|
let my_list : list (int) = [1, 2, 2]; // The head is 1
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Adding to Lists
|
### Adding to Lists
|
||||||
|
|
||||||
@ -130,9 +144,9 @@ Lists can be augmented by adding an element before the head (or, in
|
|||||||
terms of stack, by *pushing an element on top*). This operation is
|
terms of stack, by *pushing an element on top*). This operation is
|
||||||
usually called *consing* in functional languages.
|
usually called *consing* in functional languages.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
In PascaLIGO, the *cons operator* is infix and noted `#`. It is not
|
In PascaLIGO, the *cons operator* is infix and noted `#`. It is not
|
||||||
symmetric: on the left lies the element to cons, and, on the right, a
|
symmetric: on the left lies the element to cons, and, on the right, a
|
||||||
@ -143,7 +157,8 @@ you of that.)
|
|||||||
const larger_list : list (int) = 5 # my_list // [5;1;2;2]
|
const larger_list : list (int) = 5 # my_list // [5;1;2;2]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
In CameLIGO, the *cons operator* is infix and noted `::`. It is not
|
In CameLIGO, the *cons operator* is infix and noted `::`. It is not
|
||||||
symmetric: on the left lies the element to cons, and, on the right, a
|
symmetric: on the left lies the element to cons, and, on the right, a
|
||||||
@ -153,7 +168,8 @@ list on which to cons.
|
|||||||
let larger_list : int list = 5 :: my_list // [5;1;2;2]
|
let larger_list : int list = 5 :: my_list // [5;1;2;2]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
In ReasonLIGO, the *cons operator* is infix and noted `, ...`. It is
|
In ReasonLIGO, the *cons operator* is infix and noted `, ...`. It is
|
||||||
not symmetric: on the left lies the element to cons, and, on the
|
not symmetric: on the left lies the element to cons, and, on the
|
||||||
@ -162,7 +178,9 @@ right, a list on which to cons.
|
|||||||
```reasonligo group=lists
|
```reasonligo group=lists
|
||||||
let larger_list : list (int) = [5, ...my_list]; // [5,1,2,2]
|
let larger_list : list (int) = [5, ...my_list]; // [5,1,2,2]
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Functional Iteration over Lists
|
### Functional Iteration over Lists
|
||||||
|
|
||||||
@ -189,9 +207,9 @@ called `List.iter`.
|
|||||||
In the following example, a list is iterated to check that all its
|
In the following example, a list is iterated to check that all its
|
||||||
elements (integers) are strictly greater than `3`.
|
elements (integers) are strictly greater than `3`.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=lists
|
```pascaligo group=lists
|
||||||
function iter_op (const l : list (int)) : unit is
|
function iter_op (const l : list (int)) : unit is
|
||||||
@ -203,7 +221,8 @@ function iter_op (const l : list (int)) : unit is
|
|||||||
|
|
||||||
> Note that `list_iter` is *deprecated*.
|
> Note that `list_iter` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=lists
|
```cameligo group=lists
|
||||||
let iter_op (l : int list) : unit =
|
let iter_op (l : int list) : unit =
|
||||||
@ -211,7 +230,8 @@ let iter_op (l : int list) : unit =
|
|||||||
in List.iter predicate l
|
in List.iter predicate l
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=lists
|
```reasonligo group=lists
|
||||||
let iter_op = (l : list (int)) : unit => {
|
let iter_op = (l : list (int)) : unit => {
|
||||||
@ -220,7 +240,8 @@ let iter_op = (l : list (int)) : unit => {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Mapped Operation over Lists
|
#### Mapped Operation over Lists
|
||||||
@ -231,9 +252,9 @@ with the map data structure. The predefined functional iterator
|
|||||||
implementing the mapped operation over lists is called `List.map` and
|
implementing the mapped operation over lists is called `List.map` and
|
||||||
is used as follows.
|
is used as follows.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=lists
|
```pascaligo group=lists
|
||||||
function increment (const i : int): int is i + 1
|
function increment (const i : int): int is i + 1
|
||||||
@ -244,7 +265,8 @@ const plus_one : list (int) = List.map (increment, larger_list)
|
|||||||
|
|
||||||
> Note that `list_map` is *deprecated*.
|
> Note that `list_map` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=lists
|
```cameligo group=lists
|
||||||
let increment (i : int) : int = i + 1
|
let increment (i : int) : int = i + 1
|
||||||
@ -253,7 +275,8 @@ let increment (i : int) : int = i + 1
|
|||||||
let plus_one : int list = List.map increment larger_list
|
let plus_one : int list = List.map increment larger_list
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=lists
|
```reasonligo group=lists
|
||||||
let increment = (i : int) : int => i + 1;
|
let increment = (i : int) : int => i + 1;
|
||||||
@ -261,7 +284,9 @@ let increment = (i : int) : int => i + 1;
|
|||||||
// Creates a new list with all elements incremented by 1
|
// Creates a new list with all elements incremented by 1
|
||||||
let plus_one : list (int) = List.map (increment, larger_list);
|
let plus_one : list (int) = List.map (increment, larger_list);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Folded Operation over Lists
|
#### Folded Operation over Lists
|
||||||
@ -274,9 +299,9 @@ traversal of the data structure is over. The predefined functional
|
|||||||
iterator implementing the folded operation over lists is called
|
iterator implementing the folded operation over lists is called
|
||||||
`List.fold` and is used as follows.
|
`List.fold` and is used as follows.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=lists
|
```pascaligo group=lists
|
||||||
function sum (const acc : int; const i : int): int is acc + i
|
function sum (const acc : int; const i : int): int is acc + i
|
||||||
@ -285,20 +310,24 @@ const sum_of_elements : int = List.fold (sum, my_list, 0)
|
|||||||
|
|
||||||
> Note that `list_fold` is *deprecated*.
|
> Note that `list_fold` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=lists
|
```cameligo group=lists
|
||||||
let sum (acc, i: int * int) : int = acc + i
|
let sum (acc, i: int * int) : int = acc + i
|
||||||
let sum_of_elements : int = List.fold sum my_list 0
|
let sum_of_elements : int = List.fold sum my_list 0
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=lists
|
```reasonligo group=lists
|
||||||
let sum = ((result, i): (int, int)): int => result + i;
|
let sum = ((result, i): (int, int)): int => result + i;
|
||||||
let sum_of_elements : int = List.fold (sum, my_list, 0);
|
let sum_of_elements : int = List.fold (sum, my_list, 0);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Sets
|
## Sets
|
||||||
|
|
||||||
@ -309,9 +338,9 @@ whereas they can be repeated in a *list*.
|
|||||||
|
|
||||||
### Empty Sets
|
### Empty Sets
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
In PascaLIGO, the notation for sets is similar to that for lists,
|
In PascaLIGO, the notation for sets is similar to that for lists,
|
||||||
except the keyword `set` is used before:
|
except the keyword `set` is used before:
|
||||||
@ -319,7 +348,9 @@ except the keyword `set` is used before:
|
|||||||
```pascaligo group=sets
|
```pascaligo group=sets
|
||||||
const my_set : set (int) = set []
|
const my_set : set (int) = set []
|
||||||
```
|
```
|
||||||
<!--CameLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
In CameLIGO, the empty set is denoted by the predefined value
|
In CameLIGO, the empty set is denoted by the predefined value
|
||||||
`Set.empty`.
|
`Set.empty`.
|
||||||
@ -328,7 +359,8 @@ In CameLIGO, the empty set is denoted by the predefined value
|
|||||||
let my_set : int set = Set.empty
|
let my_set : int set = Set.empty
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
In ReasonLIGO, the empty set is denoted by the predefined value
|
In ReasonLIGO, the empty set is denoted by the predefined value
|
||||||
`Set.empty`.
|
`Set.empty`.
|
||||||
@ -336,13 +368,15 @@ In ReasonLIGO, the empty set is denoted by the predefined value
|
|||||||
```reasonligo group=sets
|
```reasonligo group=sets
|
||||||
let my_set : set (int) = Set.empty;
|
let my_set : set (int) = Set.empty;
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Non-empty Sets
|
### Non-empty Sets
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
In PascaLIGO, the notation for sets is similar to that for lists,
|
In PascaLIGO, the notation for sets is similar to that for lists,
|
||||||
except the keyword `set` is used before:
|
except the keyword `set` is used before:
|
||||||
@ -359,7 +393,8 @@ gitlab-pages/docs/language-basics/src/sets-lists-tuples/sets.ligo my_set
|
|||||||
# Outputs: { 3 ; 2 ; 1 }
|
# Outputs: { 3 ; 2 ; 1 }
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
In CameLIGO, there is no predefined syntactic construct for sets: you
|
In CameLIGO, there is no predefined syntactic construct for sets: you
|
||||||
must build your set by adding to the empty set. (This is the way in
|
must build your set by adding to the empty set. (This is the way in
|
||||||
@ -379,7 +414,8 @@ gitlab-pages/docs/language-basics/src/sets-lists-tuples/sets.mligo my_set
|
|||||||
# Outputs: { 3 ; 2 ; 1 }
|
# Outputs: { 3 ; 2 ; 1 }
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
In ReasonLIGO, there is no predefined syntactic construct for sets:
|
In ReasonLIGO, there is no predefined syntactic construct for sets:
|
||||||
you must build your set by adding to the empty set. (This is the way
|
you must build your set by adding to the empty set. (This is the way
|
||||||
@ -399,13 +435,15 @@ ligo evaluate-value
|
|||||||
gitlab-pages/docs/language-basics/src/sets-lists-tuples/sets.religo my_set
|
gitlab-pages/docs/language-basics/src/sets-lists-tuples/sets.religo my_set
|
||||||
# Outputs: { 3 ; 2 ; 1 }
|
# Outputs: { 3 ; 2 ; 1 }
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
### Set Membership
|
### Set Membership
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
PascaLIGO features a special keyword `contains` that operates like an
|
PascaLIGO features a special keyword `contains` that operates like an
|
||||||
infix operator checking membership in a set.
|
infix operator checking membership in a set.
|
||||||
@ -414,7 +452,8 @@ infix operator checking membership in a set.
|
|||||||
const contains_3 : bool = my_set contains 3
|
const contains_3 : bool = my_set contains 3
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
In CameLIGO, the predefined predicate `Set.mem` tests for membership
|
In CameLIGO, the predefined predicate `Set.mem` tests for membership
|
||||||
in a set as follows:
|
in a set as follows:
|
||||||
@ -423,7 +462,8 @@ in a set as follows:
|
|||||||
let contains_3 : bool = Set.mem 3 my_set
|
let contains_3 : bool = Set.mem 3 my_set
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
In ReasonLIGO, the predefined predicate `Set.mem` tests for membership
|
In ReasonLIGO, the predefined predicate `Set.mem` tests for membership
|
||||||
in a set as follows:
|
in a set as follows:
|
||||||
@ -432,7 +472,8 @@ in a set as follows:
|
|||||||
let contains_3 : bool = Set.mem (3, my_set);
|
let contains_3 : bool = Set.mem (3, my_set);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Cardinal of Sets
|
### Cardinal of Sets
|
||||||
@ -440,9 +481,9 @@ let contains_3 : bool = Set.mem (3, my_set);
|
|||||||
The predefined function `Set.size` returns the number of
|
The predefined function `Set.size` returns the number of
|
||||||
elements in a given set as follows.
|
elements in a given set as follows.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=sets
|
```pascaligo group=sets
|
||||||
const cardinal : nat = Set.size (my_set)
|
const cardinal : nat = Set.size (my_set)
|
||||||
@ -450,18 +491,22 @@ const cardinal : nat = Set.size (my_set)
|
|||||||
|
|
||||||
> Note that `size` is *deprecated*.
|
> Note that `size` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=sets
|
```cameligo group=sets
|
||||||
let cardinal : nat = Set.size my_set
|
let cardinal : nat = Set.size my_set
|
||||||
```
|
```
|
||||||
<!--ReasonLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=sets
|
```reasonligo group=sets
|
||||||
let cardinal : nat = Set.size (my_set);
|
let cardinal : nat = Set.size (my_set);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Updating Sets
|
### Updating Sets
|
||||||
@ -469,9 +514,9 @@ let cardinal : nat = Set.size (my_set);
|
|||||||
There are two ways to update a set, that is to add or remove from
|
There are two ways to update a set, that is to add or remove from
|
||||||
it.
|
it.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
In PascaLIGO, either we create a new set from the given one, or we
|
In PascaLIGO, either we create a new set from the given one, or we
|
||||||
modify it in-place. First, let us consider the former way:
|
modify it in-place. First, let us consider the former way:
|
||||||
@ -502,7 +547,8 @@ function update (var s : set (int)) : set (int) is block {
|
|||||||
const new_set : set (int) = update (my_set)
|
const new_set : set (int) = update (my_set)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
In CameLIGO, we can use the predefined functions `Set.add` and
|
In CameLIGO, we can use the predefined functions `Set.add` and
|
||||||
`Set.remove`. We update a given set by creating another one, with or
|
`Set.remove`. We update a given set by creating another one, with or
|
||||||
@ -513,7 +559,8 @@ let larger_set : int set = Set.add 4 my_set
|
|||||||
let smaller_set : int set = Set.remove 3 my_set
|
let smaller_set : int set = Set.remove 3 my_set
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
In ReasonLIGO, we can use the predefined functions `Set.add` and
|
In ReasonLIGO, we can use the predefined functions `Set.add` and
|
||||||
`Set.remove`. We update a given set by creating another one, with or
|
`Set.remove`. We update a given set by creating another one, with or
|
||||||
@ -523,7 +570,9 @@ without some elements.
|
|||||||
let larger_set : set (int) = Set.add (4, my_set);
|
let larger_set : set (int) = Set.add (4, my_set);
|
||||||
let smaller_set : set (int) = Set.remove (3, my_set);
|
let smaller_set : set (int) = Set.remove (3, my_set);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Functional Iteration over Sets
|
### Functional Iteration over Sets
|
||||||
@ -549,9 +598,9 @@ over sets is called `Set.iter`. In the following example, a set is
|
|||||||
iterated to check that all its elements (integers) are greater than
|
iterated to check that all its elements (integers) are greater than
|
||||||
`3`.
|
`3`.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=sets
|
```pascaligo group=sets
|
||||||
function iter_op (const s : set (int)) : unit is
|
function iter_op (const s : set (int)) : unit is
|
||||||
@ -563,7 +612,8 @@ function iter_op (const s : set (int)) : unit is
|
|||||||
|
|
||||||
> Note that `set_iter` is *deprecated*.
|
> Note that `set_iter` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=sets
|
```cameligo group=sets
|
||||||
let iter_op (s : int set) : unit =
|
let iter_op (s : int set) : unit =
|
||||||
@ -571,7 +621,8 @@ let iter_op (s : int set) : unit =
|
|||||||
in Set.iter predicate s
|
in Set.iter predicate s
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=sets
|
```reasonligo group=sets
|
||||||
let iter_op = (s : set (int)) : unit => {
|
let iter_op = (s : set (int)) : unit => {
|
||||||
@ -580,7 +631,8 @@ let iter_op = (s : set (int)) : unit => {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- #### Mapped Operation (NOT IMPLEMENTED YET) -->
|
<!-- #### Mapped Operation (NOT IMPLEMENTED YET) -->
|
||||||
@ -638,8 +690,9 @@ enables having a partial result that becomes complete when the
|
|||||||
traversal of the data structure is over. The predefined fold over sets
|
traversal of the data structure is over. The predefined fold over sets
|
||||||
is called `Set.fold`.
|
is called `Set.fold`.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=sets
|
```pascaligo group=sets
|
||||||
function sum (const acc : int; const i : int): int is acc + i
|
function sum (const acc : int; const i : int): int is acc + i
|
||||||
const sum_of_elements : int = Set.fold (sum, my_set, 0)
|
const sum_of_elements : int = Set.fold (sum, my_set, 0)
|
||||||
@ -658,15 +711,21 @@ function loop (const s : set (int)) : int is block {
|
|||||||
} with sum
|
} with sum
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=sets
|
```cameligo group=sets
|
||||||
let sum (acc, i : int * int) : int = acc + i
|
let sum (acc, i : int * int) : int = acc + i
|
||||||
let sum_of_elements : int = Set.fold sum my_set 0
|
let sum_of_elements : int = Set.fold sum my_set 0
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=sets
|
```reasonligo group=sets
|
||||||
let sum = ((acc, i) : (int, int)) : int => acc + i;
|
let sum = ((acc, i) : (int, int)) : int => acc + i;
|
||||||
let sum_of_elements : int = Set.fold (sum, my_set, 0);
|
let sum_of_elements : int = Set.fold (sum, my_set, 0);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,28 +3,40 @@ id: strings
|
|||||||
title: Strings
|
title: Strings
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
Strings are defined using the built-in `string` type like this:
|
Strings are defined using the built-in `string` type like this:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```
|
```
|
||||||
const a : string = "Hello Alice"
|
const a : string = "Hello Alice"
|
||||||
```
|
```
|
||||||
<!--CameLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```
|
```
|
||||||
let a : string = "Hello Alice"
|
let a : string = "Hello Alice"
|
||||||
```
|
```
|
||||||
<!--ReasonLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let a : string = "Hello Alice";
|
let a : string = "Hello Alice";
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Concatenating Strings
|
## Concatenating Strings
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
Strings can be concatenated using the `^` operator.
|
Strings can be concatenated using the `^` operator.
|
||||||
|
|
||||||
```pascaligo group=a
|
```pascaligo group=a
|
||||||
@ -32,7 +44,10 @@ const name : string = "Alice"
|
|||||||
const greeting : string = "Hello"
|
const greeting : string = "Hello"
|
||||||
const full_greeting : string = greeting ^ " " ^ name
|
const full_greeting : string = greeting ^ " " ^ name
|
||||||
```
|
```
|
||||||
<!--CameLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
Strings can be concatenated using the `^` operator.
|
Strings can be concatenated using the `^` operator.
|
||||||
|
|
||||||
```cameligo group=a
|
```cameligo group=a
|
||||||
@ -40,7 +55,10 @@ let name : string = "Alice"
|
|||||||
let greeting : string = "Hello"
|
let greeting : string = "Hello"
|
||||||
let full_greeting : string = greeting ^ " " ^ name
|
let full_greeting : string = greeting ^ " " ^ name
|
||||||
```
|
```
|
||||||
<!--ReasonLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
Strings can be concatenated using the `++` operator.
|
Strings can be concatenated using the `++` operator.
|
||||||
|
|
||||||
```reasonligo group=a
|
```reasonligo group=a
|
||||||
@ -48,15 +66,18 @@ let name : string = "Alice";
|
|||||||
let greeting : string = "Hello";
|
let greeting : string = "Hello";
|
||||||
let full_greeting : string = greeting ++ " " ++ name;
|
let full_greeting : string = greeting ++ " " ++ name;
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Slicing Strings
|
## Slicing Strings
|
||||||
|
|
||||||
Strings can be sliced using a built-in function:
|
Strings can be sliced using a built-in function:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=b
|
```pascaligo group=b
|
||||||
const name : string = "Alice"
|
const name : string = "Alice"
|
||||||
const slice : string = String.slice (0n, 1n, name)
|
const slice : string = String.slice (0n, 1n, name)
|
||||||
@ -64,19 +85,24 @@ const slice : string = String.slice (0n, 1n, name)
|
|||||||
|
|
||||||
> Note that `string_slide` is *deprecated*.
|
> Note that `string_slide` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=b
|
```cameligo group=b
|
||||||
let name : string = "Alice"
|
let name : string = "Alice"
|
||||||
let slice : string = String.slice 0n 1n name
|
let slice : string = String.slice 0n 1n name
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=b
|
```reasonligo group=b
|
||||||
let name : string = "Alice";
|
let name : string = "Alice";
|
||||||
let slice : string = String.slice (0n, 1n, name);
|
let slice : string = String.slice (0n, 1n, name);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
> ⚠️ Notice that the offset and length of the slice are natural
|
> ⚠️ Notice that the offset and length of the slice are natural
|
||||||
> numbers.
|
> numbers.
|
||||||
@ -85,8 +111,9 @@ let slice : string = String.slice (0n, 1n, name);
|
|||||||
|
|
||||||
The length of a string can be found using a built-in function:
|
The length of a string can be found using a built-in function:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=c
|
```pascaligo group=c
|
||||||
const name : string = "Alice"
|
const name : string = "Alice"
|
||||||
const length : nat = String.length (name) // length = 5
|
const length : nat = String.length (name) // length = 5
|
||||||
@ -94,15 +121,21 @@ const length : nat = String.length (name) // length = 5
|
|||||||
|
|
||||||
> Note that `size` is *deprecated*.
|
> Note that `size` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=c
|
```cameligo group=c
|
||||||
let name : string = "Alice"
|
let name : string = "Alice"
|
||||||
let length : nat = String.size name // length = 5
|
let length : nat = String.size name // length = 5
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=c
|
```reasonligo group=c
|
||||||
let name : string = "Alice";
|
let name : string = "Alice";
|
||||||
let length : nat = String.size (name); // length == 5
|
let length : nat = String.size (name); // length == 5
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ id: tezos-specific
|
|||||||
title: Tezos Domain-Specific Operations
|
title: Tezos Domain-Specific Operations
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
LIGO is a programming language for writing Tezos smart contracts. It
|
LIGO is a programming language for writing Tezos smart contracts. It
|
||||||
would be a little odd if it did not have any Tezos specific
|
would be a little odd if it did not have any Tezos specific
|
||||||
functions. This page will tell you about them.
|
functions. This page will tell you about them.
|
||||||
@ -20,9 +22,10 @@ functionality can be accessed from within LIGO.
|
|||||||
> untrusted source or casting the result to the wrong type. Do not use
|
> untrusted source or casting the result to the wrong type. Do not use
|
||||||
> the corresponding LIGO functions without doing your homework first.
|
> the corresponding LIGO functions without doing your homework first.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=a
|
```pascaligo group=a
|
||||||
function id_string (const p : string) : option (string) is block {
|
function id_string (const p : string) : option (string) is block {
|
||||||
const packed : bytes = bytes_pack (p)
|
const packed : bytes = bytes_pack (p)
|
||||||
@ -31,14 +34,18 @@ function id_string (const p : string) : option (string) is block {
|
|||||||
|
|
||||||
> Note that `bytes_unpack` is *deprecated*.
|
> Note that `bytes_unpack` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=a
|
```cameligo group=a
|
||||||
let id_string (p : string) : string option =
|
let id_string (p : string) : string option =
|
||||||
let packed: bytes = Bytes.pack p in
|
let packed: bytes = Bytes.pack p in
|
||||||
(Bytes.unpack packed : string option)
|
(Bytes.unpack packed : string option)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=a
|
```reasonligo group=a
|
||||||
let id_string = (p : string) : option (string) => {
|
let id_string = (p : string) : option (string) => {
|
||||||
let packed : bytes = Bytes.pack (p);
|
let packed : bytes = Bytes.pack (p);
|
||||||
@ -46,7 +53,8 @@ let id_string = (p : string) : option (string) => {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Hashing Keys
|
## Hashing Keys
|
||||||
|
|
||||||
@ -56,9 +64,10 @@ if this were not the case, hashes are much smaller than keys, and
|
|||||||
storage on blockchains comes at a cost premium. You can hash keys with
|
storage on blockchains comes at a cost premium. You can hash keys with
|
||||||
a predefined functions returning a value of type `key_hash`.
|
a predefined functions returning a value of type `key_hash`.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=b
|
```pascaligo group=b
|
||||||
function check_hash_key (const kh1 : key_hash; const k2 : key) : bool * key_hash is
|
function check_hash_key (const kh1 : key_hash; const k2 : key) : bool * key_hash is
|
||||||
block {
|
block {
|
||||||
@ -68,14 +77,18 @@ function check_hash_key (const kh1 : key_hash; const k2 : key) : bool * key_hash
|
|||||||
} with (ret, kh2)
|
} with (ret, kh2)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=b
|
```cameligo group=b
|
||||||
let check_hash_key (kh1, k2 : key_hash * key) : bool * key_hash =
|
let check_hash_key (kh1, k2 : key_hash * key) : bool * key_hash =
|
||||||
let kh2 : key_hash = Crypto.hash_key k2 in
|
let kh2 : key_hash = Crypto.hash_key k2 in
|
||||||
if kh1 = kh2 then true, kh2 else false, kh2
|
if kh1 = kh2 then true, kh2 else false, kh2
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=b
|
```reasonligo group=b
|
||||||
let check_hash_key = ((kh1, k2) : (key_hash, key)) : (bool, key_hash) => {
|
let check_hash_key = ((kh1, k2) : (key_hash, key)) : (bool, key_hash) => {
|
||||||
let kh2 : key_hash = Crypto.hash_key (k2);
|
let kh2 : key_hash = Crypto.hash_key (k2);
|
||||||
@ -83,7 +96,8 @@ let check_hash_key = ((kh1, k2) : (key_hash, key)) : (bool, key_hash) => {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Checking Signatures
|
## Checking Signatures
|
||||||
|
|
||||||
@ -97,9 +111,10 @@ asynchronously. You can do this in LIGO using the `key` and
|
|||||||
> because that would require storing a private key on chain, at which
|
> because that would require storing a private key on chain, at which
|
||||||
> point it is not... private anymore.
|
> point it is not... private anymore.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=c
|
```pascaligo group=c
|
||||||
function check_signature
|
function check_signature
|
||||||
(const pk : key;
|
(const pk : key;
|
||||||
@ -110,20 +125,25 @@ function check_signature
|
|||||||
|
|
||||||
> Note that `crypto_check` is *deprecated*.
|
> Note that `crypto_check` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=c
|
```cameligo group=c
|
||||||
let check_signature (pk, signed, msg : key * signature * bytes) : bool =
|
let check_signature (pk, signed, msg : key * signature * bytes) : bool =
|
||||||
Crypto.check pk signed msg
|
Crypto.check pk signed msg
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=c
|
```reasonligo group=c
|
||||||
let check_signature =
|
let check_signature =
|
||||||
((pk, signed, msg) : (key, signature, bytes)) : bool =>
|
((pk, signed, msg) : (key, signature, bytes)) : bool =>
|
||||||
Crypto.check (pk, signed, msg);
|
Crypto.check (pk, signed, msg);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Contract's Own Address
|
## Contract's Own Address
|
||||||
|
|
||||||
@ -136,24 +156,29 @@ can do it with `Tezos.self_address`.
|
|||||||
> contract is only allowed at the top-level. Using it in an embedded
|
> contract is only allowed at the top-level. Using it in an embedded
|
||||||
> function will cause an error.
|
> function will cause an error.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=d
|
```pascaligo group=d
|
||||||
const current_addr : address = Tezos.self_address
|
const current_addr : address = Tezos.self_address
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=d
|
```cameligo group=d
|
||||||
let current_addr : address = Tezos.self_address
|
let current_addr : address = Tezos.self_address
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=d
|
```reasonligo group=d
|
||||||
let current_addr : address = Tezos.self_address;
|
let current_addr : address = Tezos.self_address;
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
## Origination of a contract
|
## Origination of a contract
|
||||||
|
|
||||||
@ -163,9 +188,8 @@ The return value is a pair of type `(operation * address)`.
|
|||||||
> ⚠️ Due to limitations in Michelson, `Tezos.create_contract` first argument
|
> ⚠️ Due to limitations in Michelson, `Tezos.create_contract` first argument
|
||||||
> must be inlined and must not contain references to free variables
|
> must be inlined and must not contain references to free variables
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
```pascaligo group=e
|
```pascaligo group=e
|
||||||
const origination : operation * address = Tezos.create_contract (
|
const origination : operation * address = Tezos.create_contract (
|
||||||
function (const p : nat; const s : string): list(operation) * string is ((nil : list(operation)), s),
|
function (const p : nat; const s : string): list(operation) * string is ((nil : list(operation)), s),
|
||||||
@ -174,7 +198,9 @@ const origination : operation * address = Tezos.create_contract (
|
|||||||
"initial_storage")
|
"initial_storage")
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=e
|
```cameligo group=e
|
||||||
let origination : operation * address = Tezos.create_contract
|
let origination : operation * address = Tezos.create_contract
|
||||||
(fun (p, s : nat * string) -> (([] : operation list), s))
|
(fun (p, s : nat * string) -> (([] : operation list), s))
|
||||||
@ -183,7 +209,9 @@ let origination : operation * address = Tezos.create_contract
|
|||||||
"initial_storage"
|
"initial_storage"
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=e
|
```reasonligo group=e
|
||||||
let origination : (operation, address) = Tezos.create_contract (
|
let origination : (operation, address) = Tezos.create_contract (
|
||||||
((p, s) : (nat,string)) : (list(operation),string) => (([] : list(operation)), s),
|
((p, s) : (nat,string)) : (list(operation),string) => (([] : list(operation)), s),
|
||||||
@ -192,4 +220,5 @@ let origination : (operation, address) = Tezos.create_contract (
|
|||||||
"initial_storage")
|
"initial_storage")
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ id: types
|
|||||||
title: Types
|
title: Types
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
*LIGO is strongly and statically typed.* This means that the compiler
|
*LIGO is strongly and statically typed.* This means that the compiler
|
||||||
checks how your contract processes data. If it passes the test, your
|
checks how your contract processes data. If it passes the test, your
|
||||||
contract will not fail at run-time due to inconsistent assumptions on
|
contract will not fail at run-time due to inconsistent assumptions on
|
||||||
@ -22,36 +24,41 @@ maintainability of your smart contracts. For example we can choose to
|
|||||||
alias a string type as an animal breed - this will allow us to
|
alias a string type as an animal breed - this will allow us to
|
||||||
comunicate our intent with added clarity.
|
comunicate our intent with added clarity.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=a
|
```pascaligo group=a
|
||||||
type breed is string
|
type breed is string
|
||||||
const dog_breed : breed = "Saluki"
|
const dog_breed : breed = "Saluki"
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=a
|
```cameligo group=a
|
||||||
type breed = string
|
type breed = string
|
||||||
let dog_breed : breed = "Saluki"
|
let dog_breed : breed = "Saluki"
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=a
|
```reasonligo group=a
|
||||||
type breed = string;
|
type breed = string;
|
||||||
let dog_breed : breed = "Saluki";
|
let dog_breed : breed = "Saluki";
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
> The above type definitions are aliases, which means that `breed` and
|
> The above type definitions are aliases, which means that `breed` and
|
||||||
> `string` are interchangable in all contexts.
|
> `string` are interchangable in all contexts.
|
||||||
|
|
||||||
## Simple types
|
## Simple types
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=b
|
```pascaligo group=b
|
||||||
// The type account_balances denotes maps from addresses to tez
|
// The type account_balances denotes maps from addresses to tez
|
||||||
|
|
||||||
@ -61,7 +68,9 @@ const ledger : account_balances =
|
|||||||
map [("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address) -> 10mutez]
|
map [("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address) -> 10mutez]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=b
|
```cameligo group=b
|
||||||
// The type account_balances denotes maps from addresses to tez
|
// The type account_balances denotes maps from addresses to tez
|
||||||
|
|
||||||
@ -72,7 +81,9 @@ let ledger : account_balances =
|
|||||||
[(("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address), 10mutez)]
|
[(("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address), 10mutez)]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=b
|
```reasonligo group=b
|
||||||
// The type account_balances denotes maps from addresses to tez
|
// The type account_balances denotes maps from addresses to tez
|
||||||
|
|
||||||
@ -83,7 +94,8 @@ let ledger: account_balances =
|
|||||||
([("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address, 10mutez)]);
|
([("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address, 10mutez)]);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Structured types
|
## Structured types
|
||||||
|
|
||||||
@ -96,8 +108,9 @@ types as *fields* and index them with a *field name*. In the example
|
|||||||
below you can see the definition of data types for a ledger that keeps
|
below you can see the definition of data types for a ledger that keeps
|
||||||
the balance and number of previous transactions for a given account.
|
the balance and number of previous transactions for a given account.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=c
|
```pascaligo group=c
|
||||||
// Type aliasing
|
// Type aliasing
|
||||||
|
|
||||||
@ -124,7 +137,9 @@ const my_ledger : ledger = map [
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=c
|
```cameligo group=c
|
||||||
// Type aliasing
|
// Type aliasing
|
||||||
|
|
||||||
@ -147,7 +162,9 @@ let my_ledger : ledger = Map.literal
|
|||||||
{balance = 10mutez; transactions = 5n})]
|
{balance = 10mutez; transactions = 5n})]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=c
|
```reasonligo group=c
|
||||||
// Type aliasing
|
// Type aliasing
|
||||||
|
|
||||||
@ -177,7 +194,8 @@ are dual because records are a product of types (types are bundled
|
|||||||
into a record), whereas variant types are a sum of types (they are
|
into a record), whereas variant types are a sum of types (they are
|
||||||
exclusive to each other).
|
exclusive to each other).
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Annotations
|
## Annotations
|
||||||
|
|
||||||
@ -185,9 +203,10 @@ In certain cases, the type of an expression cannot be properly
|
|||||||
inferred by the compiler. In order to help the type checker, you can
|
inferred by the compiler. In order to help the type checker, you can
|
||||||
annotate an expression with its desired type. Here is an example:
|
annotate an expression with its desired type. Here is an example:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=d
|
```pascaligo group=d
|
||||||
type parameter is Back | Claim | Withdraw
|
type parameter is Back | Claim | Withdraw
|
||||||
|
|
||||||
@ -213,7 +232,9 @@ function back (var action : unit; var store : storage) : return is
|
|||||||
end with ((nil : list (operation)), store) // Annotation
|
end with ((nil : list (operation)), store) // Annotation
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=d
|
```cameligo group=d
|
||||||
type parameter = Back | Claim | Withdraw
|
type parameter = Back | Claim | Withdraw
|
||||||
|
|
||||||
@ -239,7 +260,9 @@ let back (param, store : unit * storage) : return =
|
|||||||
| Some (x) -> no_op, store
|
| Some (x) -> no_op, store
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=d
|
```reasonligo group=d
|
||||||
type parameter = | Back | Claim | Withdraw;
|
type parameter = | Back | Claim | Withdraw;
|
||||||
|
|
||||||
@ -269,4 +292,5 @@ let back = ((param, store) : (unit, storage)) : return => {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@ id: unit-option-pattern-matching
|
|||||||
title: Unit, Option, Pattern matching
|
title: Unit, Option, Pattern matching
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
|
|
||||||
Optionals are a pervasive programing pattern in OCaml. Since Michelson
|
Optionals are a pervasive programing pattern in OCaml. Since Michelson
|
||||||
and LIGO are both inspired by OCaml, *optional types* are available in
|
and LIGO are both inspired by OCaml, *optional types* are available in
|
||||||
LIGO as well. Similarly, OCaml features a *unit* type, and LIGO
|
LIGO as well. Similarly, OCaml features a *unit* type, and LIGO
|
||||||
@ -16,15 +19,16 @@ The `unit` type in Michelson or LIGO is a predefined type that
|
|||||||
contains only one value that carries no information. It is used when
|
contains only one value that carries no information. It is used when
|
||||||
no relevant information is required or produced. Here is how it used.
|
no relevant information is required or produced. Here is how it used.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
In PascaLIGO, the unique value of the `unit` type is `Unit`.
|
In PascaLIGO, the unique value of the `unit` type is `Unit`.
|
||||||
```pascaligo group=a
|
```pascaligo group=a
|
||||||
const n : unit = Unit // Note the capital letter
|
const n : unit = Unit // Note the capital letter
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
In CameLIGO, the unique value of the `unit` type is `()`, following
|
In CameLIGO, the unique value of the `unit` type is `()`, following
|
||||||
the OCaml convention.
|
the OCaml convention.
|
||||||
@ -32,7 +36,8 @@ the OCaml convention.
|
|||||||
let n : unit = ()
|
let n : unit = ()
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
In ReasonLIGO, the unique value of the `unit` type is `()`, following
|
In ReasonLIGO, the unique value of the `unit` type is `()`, following
|
||||||
the OCaml convention.
|
the OCaml convention.
|
||||||
@ -40,7 +45,8 @@ the OCaml convention.
|
|||||||
let n : unit = ();
|
let n : unit = ();
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Variant types
|
## Variant types
|
||||||
|
|
||||||
@ -52,28 +58,35 @@ the enumerated types found in Java, C++, JavaScript etc.
|
|||||||
Here is how we define a coin as being either head or tail (and nothing
|
Here is how we define a coin as being either head or tail (and nothing
|
||||||
else):
|
else):
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=b
|
```pascaligo group=b
|
||||||
type coin is Head | Tail
|
type coin is Head | Tail
|
||||||
const head : coin = Head
|
const head : coin = Head
|
||||||
const tail : coin = Tail
|
const tail : coin = Tail
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=b
|
```cameligo group=b
|
||||||
type coin = Head | Tail
|
type coin = Head | Tail
|
||||||
let head : coin = Head
|
let head : coin = Head
|
||||||
let tail : coin = Tail
|
let tail : coin = Tail
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=b
|
```reasonligo group=b
|
||||||
type coin = Head | Tail;
|
type coin = Head | Tail;
|
||||||
let head : coin = Head;
|
let head : coin = Head;
|
||||||
let tail : coin = Tail;
|
let tail : coin = Tail;
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
The names `Head` and `Tail` in the definition of the type `coin` are
|
The names `Head` and `Tail` in the definition of the type `coin` are
|
||||||
called *data constructors*, or *variants*. In this particular, they
|
called *data constructors*, or *variants*. In this particular, they
|
||||||
@ -84,9 +97,10 @@ In general, it is interesting for variants to carry some information,
|
|||||||
and thus go beyond enumerated types. In the following, we show how to
|
and thus go beyond enumerated types. In the following, we show how to
|
||||||
define different kinds of users of a system.
|
define different kinds of users of a system.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=c
|
```pascaligo group=c
|
||||||
type id is nat
|
type id is nat
|
||||||
|
|
||||||
@ -99,7 +113,9 @@ const u : user = Admin (1000n)
|
|||||||
const g : user = Guest
|
const g : user = Guest
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=c
|
```cameligo group=c
|
||||||
type id = nat
|
type id = nat
|
||||||
|
|
||||||
@ -112,7 +128,9 @@ let u : user = Admin 1000n
|
|||||||
let g : user = Guest
|
let g : user = Guest
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=c
|
```reasonligo group=c
|
||||||
type id = nat;
|
type id = nat;
|
||||||
|
|
||||||
@ -125,7 +143,8 @@ let u : user = Admin (1000n);
|
|||||||
let g : user = Guest;
|
let g : user = Guest;
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
In LIGO, a constant constructor is equivalent to the same constructor
|
In LIGO, a constant constructor is equivalent to the same constructor
|
||||||
taking an argument of type `unit`, so, for example, `Guest` is the
|
taking an argument of type `unit`, so, for example, `Guest` is the
|
||||||
@ -141,26 +160,32 @@ type would be `None`, otherwise `Some (v)`, where `v` is some
|
|||||||
meaningful value *of any type*. An example in arithmetic is the
|
meaningful value *of any type*. An example in arithmetic is the
|
||||||
division operation:
|
division operation:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=d
|
```pascaligo group=d
|
||||||
function div (const a : nat; const b : nat) : option (nat) is
|
function div (const a : nat; const b : nat) : option (nat) is
|
||||||
if b = 0n then (None: option (nat)) else Some (a/b)
|
if b = 0n then (None: option (nat)) else Some (a/b)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=d
|
```cameligo group=d
|
||||||
let div (a, b : nat * nat) : nat option =
|
let div (a, b : nat * nat) : nat option =
|
||||||
if b = 0n then (None: nat option) else Some (a/b)
|
if b = 0n then (None: nat option) else Some (a/b)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=d
|
```reasonligo group=d
|
||||||
let div = ((a, b) : (nat, nat)) : option (nat) =>
|
let div = ((a, b) : (nat, nat)) : option (nat) =>
|
||||||
if (b == 0n) { (None: option (nat)); } else { Some (a/b); };
|
if (b == 0n) { (None: option (nat)); } else { Some (a/b); };
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Pattern matching
|
## Pattern matching
|
||||||
@ -170,8 +195,9 @@ Javascript, and can be used to route the program's control flow based
|
|||||||
on the value of a variant. Consider for example the definition of a
|
on the value of a variant. Consider for example the definition of a
|
||||||
function `flip` that flips a coin.
|
function `flip` that flips a coin.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=e
|
```pascaligo group=e
|
||||||
type coin is Head | Tail
|
type coin is Head | Tail
|
||||||
|
|
||||||
@ -190,7 +216,9 @@ flip "Head"
|
|||||||
# Outputs: Tail(Unit)
|
# Outputs: Tail(Unit)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=e
|
```cameligo group=e
|
||||||
type coin = Head | Tail
|
type coin = Head | Tail
|
||||||
|
|
||||||
@ -208,7 +236,9 @@ flip Head
|
|||||||
# Outputs: Tail(Unit)
|
# Outputs: Tail(Unit)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=e
|
```reasonligo group=e
|
||||||
type coin = | Head | Tail;
|
type coin = | Head | Tail;
|
||||||
|
|
||||||
@ -227,4 +257,5 @@ flip Head
|
|||||||
# Outputs: Tail(Unit)
|
# Outputs: Tail(Unit)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@ id: constants-and-variables
|
|||||||
title: Constants & Variables
|
title: Constants & Variables
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
|
|
||||||
The next building block after types are *constants* and *variables*.
|
The next building block after types are *constants* and *variables*.
|
||||||
|
|
||||||
## Constants
|
## Constants
|
||||||
@ -12,8 +15,9 @@ reassigned. Put in another way, they can be assigned once, at their
|
|||||||
declaration. When defining a constant you need to provide a `name`,
|
declaration. When defining a constant you need to provide a `name`,
|
||||||
`type` and a `value`:
|
`type` and a `value`:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=a
|
```pascaligo group=a
|
||||||
const age : int = 25
|
const age : int = 25
|
||||||
```
|
```
|
||||||
@ -24,7 +28,10 @@ command:
|
|||||||
ligo evaluate-value gitlab-pages/docs/language-basics/src/variables-and-constants/const.ligo age
|
ligo evaluate-value gitlab-pages/docs/language-basics/src/variables-and-constants/const.ligo age
|
||||||
# Outputs: 25
|
# Outputs: 25
|
||||||
```
|
```
|
||||||
<!--CameLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=a
|
```cameligo group=a
|
||||||
let age : int = 25
|
let age : int = 25
|
||||||
```
|
```
|
||||||
@ -36,7 +43,9 @@ ligo evaluate-value gitlab-pages/docs/language-basics/src/variables-and-constant
|
|||||||
# Outputs: 25
|
# Outputs: 25
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=a
|
```reasonligo group=a
|
||||||
let age : int = 25;
|
let age : int = 25;
|
||||||
```
|
```
|
||||||
@ -48,12 +57,13 @@ ligo evaluate-value gitlab-pages/docs/language-basics/src/variables-and-constant
|
|||||||
# Outputs: 25
|
# Outputs: 25
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Variables
|
## Variables
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
Variables, unlike constants, are *mutable*. They cannot be declared in
|
Variables, unlike constants, are *mutable*. They cannot be declared in
|
||||||
a *global scope*, but they can be declared and used within functions,
|
a *global scope*, but they can be declared and used within functions,
|
||||||
@ -88,7 +98,8 @@ ligo run-function gitlab-pages/docs/language-basics/src/variables-and-constants/
|
|||||||
# Outputs: 2
|
# Outputs: 2
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
As expected in the pure subset of a functional language, CameLIGO only
|
As expected in the pure subset of a functional language, CameLIGO only
|
||||||
features *constant values*: once they are declared, the value cannot
|
features *constant values*: once they are declared, the value cannot
|
||||||
@ -105,7 +116,9 @@ like this:
|
|||||||
ligo run-function gitlab-pages/docs/language-basics/src/variables-and-constants/add.mligo add '(1,1)'
|
ligo run-function gitlab-pages/docs/language-basics/src/variables-and-constants/add.mligo add '(1,1)'
|
||||||
# Outputs: 2
|
# Outputs: 2
|
||||||
```
|
```
|
||||||
<!--ReasonLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
As expected in the pure subset of a functional language, ReasonLIGO
|
As expected in the pure subset of a functional language, ReasonLIGO
|
||||||
only features *constant values*: once they are declared, the value
|
only features *constant values*: once they are declared, the value
|
||||||
@ -125,4 +138,5 @@ ligo run-function gitlab-pages/docs/language-basics/src/variables-and-constants/
|
|||||||
# Outputs: 2
|
# Outputs: 2
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ id: big-map-reference
|
|||||||
title: Big Maps — Scalable Maps
|
title: Big Maps — Scalable Maps
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
Ordinary maps are fine for contracts with a finite lifespan or a
|
Ordinary maps are fine for contracts with a finite lifespan or a
|
||||||
bounded number of users. For many contracts however, the intention is
|
bounded number of users. For many contracts however, the intention is
|
||||||
to have a map holding *many* entries, potentially millions of
|
to have a map holding *many* entries, potentially millions of
|
||||||
@ -14,52 +16,67 @@ interface for big maps is analogous to the one used for ordinary maps.
|
|||||||
|
|
||||||
# Declaring a Map
|
# Declaring a Map
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=big_maps
|
```pascaligo group=big_maps
|
||||||
type move is int * int
|
type move is int * int
|
||||||
type register is big_map (address, move)
|
type register is big_map (address, move)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=big_maps
|
```cameligo group=big_maps
|
||||||
type move = int * int
|
type move = int * int
|
||||||
type register = (address, move) big_map
|
type register = (address, move) big_map
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=big_maps
|
```reasonligo group=big_maps
|
||||||
type move = (int, int);
|
type move = (int, int);
|
||||||
type register = big_map (address, move);
|
type register = big_map (address, move);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Creating an Empty Big Map
|
# Creating an Empty Big Map
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=big_maps
|
```pascaligo group=big_maps
|
||||||
const empty : register = big_map []
|
const empty : register = big_map []
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=big_maps
|
```cameligo group=big_maps
|
||||||
let empty : register = Big_map.empty
|
let empty : register = Big_map.empty
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=big_maps
|
```reasonligo group=big_maps
|
||||||
let empty : register = Big_map.empty
|
let empty : register = Big_map.empty
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
# Creating a Non-empty Map
|
# Creating a Non-empty Map
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=big_maps
|
```pascaligo group=big_maps
|
||||||
const moves : register =
|
const moves : register =
|
||||||
big_map [
|
big_map [
|
||||||
@ -67,7 +84,9 @@ const moves : register =
|
|||||||
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) -> (0,3)]
|
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) -> (0,3)]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=big_maps
|
```cameligo group=big_maps
|
||||||
let moves : register =
|
let moves : register =
|
||||||
Big_map.literal [
|
Big_map.literal [
|
||||||
@ -75,42 +94,54 @@ let moves : register =
|
|||||||
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address), (0,3))]
|
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address), (0,3))]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=big_maps
|
```reasonligo group=big_maps
|
||||||
let moves : register =
|
let moves : register =
|
||||||
Big_map.literal ([
|
Big_map.literal ([
|
||||||
("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address, (1,2)),
|
("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address, (1,2)),
|
||||||
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address, (0,3))]);
|
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address, (0,3))]);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
# Accessing Values
|
# Accessing Values
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=big_maps
|
```pascaligo group=big_maps
|
||||||
const my_balance : option (move) =
|
const my_balance : option (move) =
|
||||||
moves [("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address)]
|
moves [("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address)]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=big_maps
|
```cameligo group=big_maps
|
||||||
let my_balance : move option =
|
let my_balance : move option =
|
||||||
Big_map.find_opt ("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) moves
|
Big_map.find_opt ("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) moves
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=big_maps
|
```reasonligo group=big_maps
|
||||||
let my_balance : option (move) =
|
let my_balance : option (move) =
|
||||||
Big_map.find_opt ("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address, moves);
|
Big_map.find_opt ("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address, moves);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Updating Big Maps
|
# Updating Big Maps
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=big_maps
|
```pascaligo group=big_maps
|
||||||
function add (var m : register) : register is
|
function add (var m : register) : register is
|
||||||
block {
|
block {
|
||||||
@ -120,26 +151,33 @@ function add (var m : register) : register is
|
|||||||
const updated_map : register = add (moves)
|
const updated_map : register = add (moves)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=big_maps
|
```cameligo group=big_maps
|
||||||
let updated_map : register =
|
let updated_map : register =
|
||||||
Big_map.update
|
Big_map.update
|
||||||
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) (Some (4,9)) moves
|
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) (Some (4,9)) moves
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=big_maps
|
```reasonligo group=big_maps
|
||||||
let updated_map : register =
|
let updated_map : register =
|
||||||
Big_map.update
|
Big_map.update
|
||||||
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN": address), Some ((4,9)), moves);
|
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN": address), Some ((4,9)), moves);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
# Removing Bindings
|
# Removing Bindings
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=big_maps
|
```pascaligo group=big_maps
|
||||||
function rem (var m : register) : register is
|
function rem (var m : register) : register is
|
||||||
block {
|
block {
|
||||||
@ -149,16 +187,21 @@ function rem (var m : register) : register is
|
|||||||
const updated_map : register = rem (moves)
|
const updated_map : register = rem (moves)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=big_maps
|
```cameligo group=big_maps
|
||||||
let updated_map : register =
|
let updated_map : register =
|
||||||
Map.remove ("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN": address) moves
|
Map.remove ("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN": address) moves
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=big_maps
|
```reasonligo group=big_maps
|
||||||
let updated_map : register =
|
let updated_map : register =
|
||||||
Map.remove (("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN": address), moves)
|
Map.remove (("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN": address), moves)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,62 +3,67 @@ id: bytes-reference
|
|||||||
title: Bytes — Manipulate bytes data
|
title: Bytes — Manipulate bytes data
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
## Bytes.concat(b1: bytes, b2: bytes) : bytes
|
## Bytes.concat(b1: bytes, b2: bytes) : bytes
|
||||||
|
|
||||||
Concatenate together two `bytes` arguments and return the result.
|
Concatenate together two `bytes` arguments and return the result.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function concat_op (const s : bytes) : bytes is
|
function concat_op (const s : bytes) : bytes is
|
||||||
begin skip end with bytes_concat(s , 0x7070)
|
begin skip end with bytes_concat(s , 0x7070)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let concat_op (s : bytes) : bytes =
|
let concat_op (s : bytes) : bytes =
|
||||||
Bytes.concat s 0x7070
|
Bytes.concat s 0x7070
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let concat_op = (s: bytes): bytes => Bytes.concat(s, 0x7070);
|
let concat_op = (s: bytes): bytes => Bytes.concat(s, 0x7070);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
## Bytes.slice(pos1: nat, pos2: nat, data: bytes) : bytes
|
## Bytes.slice(pos1: nat, pos2: nat, data: bytes) : bytes
|
||||||
|
|
||||||
Extract the bytes between `pos1` and `pos2`. **Positions are zero indexed and
|
Extract the bytes between `pos1` and `pos2`. **Positions are zero indexed and
|
||||||
inclusive**. For example if you gave the input "ff7a7aff" to the following:
|
inclusive**. For example if you gave the input "ff7a7aff" to the following:
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function slice_op (const s : bytes) : bytes is
|
function slice_op (const s : bytes) : bytes is
|
||||||
begin skip end with bytes_slice(1n , 2n , s)
|
begin skip end with bytes_slice(1n , 2n , s)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let slice_op (s : bytes) : bytes =
|
let slice_op (s : bytes) : bytes =
|
||||||
Bytes.slice 1n 2n s
|
Bytes.slice 1n 2n s
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```
|
```
|
||||||
let slice_op = (s: bytes): bytes => Bytes.slice(1n, 2n, s);
|
let slice_op = (s: bytes): bytes => Bytes.slice(1n, 2n, s);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
It would return "7a7a" rather than "ff7a" or "ff" or "7a".
|
It would return "7a7a" rather than "ff7a" or "ff" or "7a".
|
||||||
|
|
||||||
@ -68,23 +73,28 @@ Converts Michelson data structures to a binary format for serialization.
|
|||||||
|
|
||||||
> ⚠️ `PACK` and `UNPACK` are features of Michelson that are intended to be used by people that really know what they're doing. There are several failure cases (such as `UNPACK`ing a lambda from an untrusted source), most of which are beyond the scope of this document. Don't use these functions without doing your homework first.
|
> ⚠️ `PACK` and `UNPACK` are features of Michelson that are intended to be used by people that really know what they're doing. There are several failure cases (such as `UNPACK`ing a lambda from an untrusted source), most of which are beyond the scope of this document. Don't use these functions without doing your homework first.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function id_string (const p : string) : option(string) is block {
|
function id_string (const p : string) : option(string) is block {
|
||||||
const packed : bytes = bytes_pack(p) ;
|
const packed : bytes = bytes_pack(p) ;
|
||||||
} with (bytes_unpack(packed): option(string))
|
} with (bytes_unpack(packed): option(string))
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let id_string (p: string) : string option =
|
let id_string (p: string) : string option =
|
||||||
let packed: bytes = Bytes.pack p in
|
let packed: bytes = Bytes.pack p in
|
||||||
((Bytes.unpack packed): string option)
|
((Bytes.unpack packed): string option)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let id_string = (p: string) : option(string) => {
|
let id_string = (p: string) : option(string) => {
|
||||||
let packed : bytes = Bytes.pack(p);
|
let packed : bytes = Bytes.pack(p);
|
||||||
@ -92,7 +102,8 @@ let id_string = (p: string) : option(string) => {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Bytes.unpack(packed: bytes) : a'
|
## Bytes.unpack(packed: bytes) : a'
|
||||||
|
|
||||||
@ -101,23 +112,28 @@ serialization format to the `option` type annotated on the call.
|
|||||||
|
|
||||||
> ⚠️ `PACK` and `UNPACK` are features of Michelson that are intended to be used by people that really know what they're doing. There are several failure cases (such as `UNPACK`ing a lambda from an untrusted source), most of which are beyond the scope of this document. Don't use these functions without doing your homework first.
|
> ⚠️ `PACK` and `UNPACK` are features of Michelson that are intended to be used by people that really know what they're doing. There are several failure cases (such as `UNPACK`ing a lambda from an untrusted source), most of which are beyond the scope of this document. Don't use these functions without doing your homework first.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function id_string (const p : string) : option(string) is block {
|
function id_string (const p : string) : option(string) is block {
|
||||||
const packed : bytes = bytes_pack(p) ;
|
const packed : bytes = bytes_pack(p) ;
|
||||||
} with (bytes_unpack(packed): option(string))
|
} with (bytes_unpack(packed): option(string))
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let id_string (p: string) : string option =
|
let id_string (p: string) : string option =
|
||||||
let packed: bytes = Bytes.pack p in
|
let packed: bytes = Bytes.pack p in
|
||||||
((Bytes.unpack packed): string option)
|
((Bytes.unpack packed): string option)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let id_string = (p: string) : option(string) => {
|
let id_string = (p: string) : option(string) => {
|
||||||
let packed : bytes = Bytes.pack(p);
|
let packed : bytes = Bytes.pack(p);
|
||||||
@ -125,4 +141,5 @@ let id_string = (p: string) : option(string) => {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,93 +3,108 @@ id: crypto-reference
|
|||||||
title: Crypto — Cryptographic functions
|
title: Crypto — Cryptographic functions
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
## Crypto.blake2b(data: bytes): bytes
|
## Crypto.blake2b(data: bytes): bytes
|
||||||
|
|
||||||
Runs the [blake2b hash algorithm](https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE2)
|
Runs the [blake2b hash algorithm](https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE2)
|
||||||
over the given `bytes` data and returns a `bytes` representing the hash.
|
over the given `bytes` data and returns a `bytes` representing the hash.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function hasherman_blake (const s: bytes) : bytes is blake2b(s)
|
function hasherman_blake (const s: bytes) : bytes is blake2b(s)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let hasherman_blake (s: bytes) : bytes = Crypto.blake2b s
|
let hasherman_blake (s: bytes) : bytes = Crypto.blake2b s
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let hasherman_blake = (s: bytes) => Crypto.blake2b(s);
|
let hasherman_blake = (s: bytes) => Crypto.blake2b(s);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Crypto.sha256(data: bytes) : bytes
|
## Crypto.sha256(data: bytes) : bytes
|
||||||
|
|
||||||
Runs the [sha256 hash algorithm](https://en.wikipedia.org/wiki/SHA-2) over the given
|
Runs the [sha256 hash algorithm](https://en.wikipedia.org/wiki/SHA-2) over the given
|
||||||
`bytes` data and returns a `bytes` representing the hash.
|
`bytes` data and returns a `bytes` representing the hash.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function hasherman (const s : bytes) : bytes is
|
function hasherman (const s : bytes) : bytes is
|
||||||
begin skip end with sha_256(s)
|
begin skip end with sha_256(s)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let hasherman (s : bytes) : bytes =
|
let hasherman (s : bytes) : bytes =
|
||||||
Crypto.sha256 s
|
Crypto.sha256 s
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let hasherman = (s: bytes): bytes => Crypto.sha256(s);
|
let hasherman = (s: bytes): bytes => Crypto.sha256(s);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Crypto.sha512(data: bytes) : bytes
|
## Crypto.sha512(data: bytes) : bytes
|
||||||
|
|
||||||
Runs the [sha512 hash algorithm](https://en.wikipedia.org/wiki/SHA-2) over the given
|
Runs the [sha512 hash algorithm](https://en.wikipedia.org/wiki/SHA-2) over the given
|
||||||
`bytes` data and returns a `bytes` representing the hash.
|
`bytes` data and returns a `bytes` representing the hash.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function hasherman512 (const s: bytes) : bytes is sha_512(s)
|
function hasherman512 (const s: bytes) : bytes is sha_512(s)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let hasherman512 (s: bytes) : bytes = Crypto.sha512 s
|
let hasherman512 (s: bytes) : bytes = Crypto.sha512 s
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let hasherman512 = (s: bytes) => Crypto.sha512(s);
|
let hasherman512 = (s: bytes) => Crypto.sha512(s);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Crypto.hash_key(k: key) : key_hash
|
## Crypto.hash_key(k: key) : key_hash
|
||||||
|
|
||||||
Hashes a key for easy comparison and storage.
|
Hashes a key for easy comparison and storage.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function check_hash_key (const kh1 : key_hash; const k2 : key) : bool * key_hash is block {
|
function check_hash_key (const kh1 : key_hash; const k2 : key) : bool * key_hash is block {
|
||||||
var ret : bool := False ;
|
var ret : bool := False ;
|
||||||
@ -98,7 +113,9 @@ function check_hash_key (const kh1 : key_hash; const k2 : key) : bool * key_hash
|
|||||||
} with (ret, kh2)
|
} with (ret, kh2)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let check_hash_key (kh1, k2: key_hash * key) : bool * key_hash =
|
let check_hash_key (kh1, k2: key_hash * key) : bool * key_hash =
|
||||||
let kh2 : key_hash = Crypto.hash_key k2 in
|
let kh2 : key_hash = Crypto.hash_key k2 in
|
||||||
@ -107,7 +124,9 @@ let check_hash_key (kh1, k2: key_hash * key) : bool * key_hash =
|
|||||||
else (false, kh2)
|
else (false, kh2)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let check_hash_key = ((kh1, k2): (key_hash, key)) : (bool, key_hash) => {
|
let check_hash_key = ((kh1, k2): (key_hash, key)) : (bool, key_hash) => {
|
||||||
let kh2 : key_hash = Crypto.hash_key(k2);
|
let kh2 : key_hash = Crypto.hash_key(k2);
|
||||||
@ -120,7 +139,8 @@ let check_hash_key = ((kh1, k2): (key_hash, key)) : (bool, key_hash) => {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Crypto.check(pk: key, signed: signature, data: bytes) : bool
|
## Crypto.check(pk: key, signed: signature, data: bytes) : bool
|
||||||
|
|
||||||
@ -128,9 +148,10 @@ Check that a message has been signed by a particular key.
|
|||||||
|
|
||||||
> ⚠️ There is no way to *generate* a signed message in LIGO. This is because that would require storing a private key on chain, at which point it isn't very private anymore.
|
> ⚠️ There is no way to *generate* a signed message in LIGO. This is because that would require storing a private key on chain, at which point it isn't very private anymore.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function check_signature
|
function check_signature
|
||||||
(const pk: key;
|
(const pk: key;
|
||||||
@ -139,17 +160,22 @@ function check_signature
|
|||||||
is crypto_check(pk, signed, msg)
|
is crypto_check(pk, signed, msg)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let check_signature (pk, signed, msg: key * signature * bytes) : bool =
|
let check_signature (pk, signed, msg: key * signature * bytes) : bool =
|
||||||
Crypto.check pk signed msg
|
Crypto.check pk signed msg
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let check_signature = ((pk, signed, msg): (key, signature, bytes)) : bool => {
|
let check_signature = ((pk, signed, msg): (key, signature, bytes)) : bool => {
|
||||||
Crypto.check(pk, signed, msg);
|
Crypto.check(pk, signed, msg);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,13 +3,16 @@ id: current-reference
|
|||||||
title: Tezos - Things relating to the current execution context
|
title: Tezos - Things relating to the current execution context
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
# Tezos.balance
|
# Tezos.balance
|
||||||
|
|
||||||
Get the balance for the contract.
|
Get the balance for the contract.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function main (const p : unit; const s: tez) : list (operation) * tez is
|
function main (const p : unit; const s: tez) : list (operation) * tez is
|
||||||
((nil : list (operation)), Tezos.balance)
|
((nil : list (operation)), Tezos.balance)
|
||||||
@ -17,14 +20,18 @@ function main (const p : unit; const s: tez) : list (operation) * tez is
|
|||||||
|
|
||||||
> Note that `balance` and `Current.balance` are *deprecated*.
|
> Note that `balance` and `Current.balance` are *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let main (p,s : unit * tez) = ([] : operation list), Tezos.balance
|
let main (p,s : unit * tez) = ([] : operation list), Tezos.balance
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `balance` and `Current.balance` are *deprecated*.
|
> Note that `balance` and `Current.balance` are *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let main = ((p,s) : (unit, tez)) =>
|
let main = ((p,s) : (unit, tez)) =>
|
||||||
([]: list (operation), Tezos.balance);
|
([]: list (operation), Tezos.balance);
|
||||||
@ -32,7 +39,8 @@ let main = ((p,s) : (unit, tez)) =>
|
|||||||
|
|
||||||
> Note that `balance` and `Current.balance` are *deprecated*.
|
> Note that `balance` and `Current.balance` are *deprecated*.
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Tezos.now
|
## Tezos.now
|
||||||
|
|
||||||
@ -45,8 +53,9 @@ smart contracts like this:
|
|||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
#### 24 hours from now
|
#### 24 hours from now
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--Pascaligo-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=b
|
```pascaligo group=b
|
||||||
const today: timestamp = Tezos.now;
|
const today: timestamp = Tezos.now;
|
||||||
const one_day: int = 86_400;
|
const one_day: int = 86_400;
|
||||||
@ -57,7 +66,9 @@ const one_day_later: timestamp = some_date + one_day;
|
|||||||
|
|
||||||
> Note that `now` is *deprecated*.
|
> Note that `now` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=b
|
```cameligo group=b
|
||||||
let today: timestamp = Tezos.now
|
let today: timestamp = Tezos.now
|
||||||
let one_day: int = 86_400
|
let one_day: int = 86_400
|
||||||
@ -68,7 +79,9 @@ let one_day_later: timestamp = some_date + one_day
|
|||||||
|
|
||||||
> Note that `Current.time` is *deprecated*.
|
> Note that `Current.time` is *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=b
|
```reasonligo group=b
|
||||||
let today: timestamp = Tezos.now;
|
let today: timestamp = Tezos.now;
|
||||||
let one_day: int = 86_400;
|
let one_day: int = 86_400;
|
||||||
@ -79,12 +92,14 @@ let one_day_later: timestamp = some_date + one_day;
|
|||||||
|
|
||||||
> Note that `Current.time` is *deprecated*.
|
> Note that `Current.time` is *deprecated*.
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
#### 24 hours ago
|
#### 24 hours ago
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--Pascaligo-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=c
|
```pascaligo group=c
|
||||||
const today: timestamp = Tezos.now;
|
const today: timestamp = Tezos.now;
|
||||||
const one_day: int = 86_400;
|
const one_day: int = 86_400;
|
||||||
@ -93,7 +108,9 @@ const in_24_hrs: timestamp = today - one_day;
|
|||||||
|
|
||||||
> Note that `now` is *deprecated*.
|
> Note that `now` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=c
|
```cameligo group=c
|
||||||
let today: timestamp = Tezos.now
|
let today: timestamp = Tezos.now
|
||||||
let one_day: int = 86_400
|
let one_day: int = 86_400
|
||||||
@ -102,7 +119,9 @@ let in_24_hrs: timestamp = today - one_day
|
|||||||
|
|
||||||
> Note that `Current.time` is *deprecated*.
|
> Note that `Current.time` is *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=c
|
```reasonligo group=c
|
||||||
let today: timestamp = Tezos.now;
|
let today: timestamp = Tezos.now;
|
||||||
let one_day: int = 86_400;
|
let one_day: int = 86_400;
|
||||||
@ -111,36 +130,43 @@ let in_24_hrs: timestamp = today - one_day;
|
|||||||
|
|
||||||
> Note that `Current.time` is *deprecated*.
|
> Note that `Current.time` is *deprecated*.
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
#### Comparing Timestamps
|
#### Comparing Timestamps
|
||||||
|
|
||||||
You can also compare timestamps using the same comparison operators as
|
You can also compare timestamps using the same comparison operators as
|
||||||
for numbers
|
for numbers
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--Pascaligo-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=c
|
```pascaligo group=c
|
||||||
const not_tommorow: bool = (Tezos.now = in_24_hrs)
|
const not_tommorow: bool = (Tezos.now = in_24_hrs)
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `now` is *deprecated*.
|
> Note that `now` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=c
|
```cameligo group=c
|
||||||
let not_tomorrow: bool = (Tezos.now = in_24_hrs)
|
let not_tomorrow: bool = (Tezos.now = in_24_hrs)
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `Current.time` is *deprecated*.
|
> Note that `Current.time` is *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=c
|
```reasonligo group=c
|
||||||
let not_tomorrow: bool = (Tezos.now == in_24_hrs);
|
let not_tomorrow: bool = (Tezos.now == in_24_hrs);
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `Current.time` is *deprecated*.
|
> Note that `Current.time` is *deprecated*.
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Amount
|
## Amount
|
||||||
@ -148,9 +174,10 @@ let not_tomorrow: bool = (Tezos.now == in_24_hrs);
|
|||||||
Get the amount of tez provided by the sender to complete this
|
Get the amount of tez provided by the sender to complete this
|
||||||
transaction.
|
transaction.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function threshold (const p : unit) : int is
|
function threshold (const p : unit) : int is
|
||||||
if Tezos.amount = 100tz then 42 else 0
|
if Tezos.amount = 100tz then 42 else 0
|
||||||
@ -158,14 +185,18 @@ function threshold (const p : unit) : int is
|
|||||||
|
|
||||||
> Note that `amount` is *deprecated*.
|
> Note that `amount` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let threshold (p : unit) : int = if Tezos.amount = 100tz then 42 else 0
|
let threshold (p : unit) : int = if Tezos.amount = 100tz then 42 else 0
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `Current.amount` is *deprecated*.
|
> Note that `Current.amount` is *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let threshold = (p : unit) : int =>
|
let threshold = (p : unit) : int =>
|
||||||
if (Tezos.amount == 100tz) { 42; } else { 0; };
|
if (Tezos.amount == 100tz) { 42; } else { 0; };
|
||||||
@ -173,45 +204,53 @@ let threshold = (p : unit) : int =>
|
|||||||
|
|
||||||
> Note that `Current.amount` is *deprecated*.
|
> Note that `Current.amount` is *deprecated*.
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Sender
|
## Sender
|
||||||
|
|
||||||
Get the address that initiated the current transaction.
|
Get the address that initiated the current transaction.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function main (const p : unit) : address is Tezos.sender
|
function main (const p : unit) : address is Tezos.sender
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `sender` is *deprecated*.
|
> Note that `sender` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let main (p: unit) : address = Tezos.sender
|
let main (p: unit) : address = Tezos.sender
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `Current.sender` is *deprecated*.
|
> Note that `Current.sender` is *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let main = (p : unit) : address => Tezos.sender;
|
let main = (p : unit) : address => Tezos.sender;
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `Current.sender` is *deprecated*.
|
> Note that `Current.sender` is *deprecated*.
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Address
|
## Address
|
||||||
|
|
||||||
Get the address associated with a value of type `contract`.
|
Get the address associated with a value of type `contract`.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function main (const p : key_hash) : address is block {
|
function main (const p : key_hash) : address is block {
|
||||||
const c : contract (unit) = Tezos.implicit_account (p)
|
const c : contract (unit) = Tezos.implicit_account (p)
|
||||||
@ -220,7 +259,9 @@ function main (const p : key_hash) : address is block {
|
|||||||
|
|
||||||
> Note that `implicit_account` and `address` are *deprecated*.
|
> Note that `implicit_account` and `address` are *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let main (p : key_hash) =
|
let main (p : key_hash) =
|
||||||
let c : unit contract = Tezos.implicit_account p
|
let c : unit contract = Tezos.implicit_account p
|
||||||
@ -230,7 +271,9 @@ let main (p : key_hash) =
|
|||||||
> Note that `Current.implicit_account` and `Current.address` are
|
> Note that `Current.implicit_account` and `Current.address` are
|
||||||
> *deprecated*.
|
> *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let main = (p : key_hash) : address => {
|
let main = (p : key_hash) : address => {
|
||||||
let c : contract (unit) = Tezos.implicit_account (p);
|
let c : contract (unit) = Tezos.implicit_account (p);
|
||||||
@ -241,36 +284,43 @@ let main = (p : key_hash) : address => {
|
|||||||
> Note that `Current.implicit_account` and `Current.address` are
|
> Note that `Current.implicit_account` and `Current.address` are
|
||||||
> *deprecated*.
|
> *deprecated*.
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Self Address
|
## Self Address
|
||||||
|
|
||||||
Get the address of the currently running contract.
|
Get the address of the currently running contract.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function main (const p : unit) : address is Tezos.self_address
|
function main (const p : unit) : address is Tezos.self_address
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `self_address` is *deprecated*.
|
> Note that `self_address` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let main (p : unit) : address = Tezos.self_address
|
let main (p : unit) : address = Tezos.self_address
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `Current.self_address` is *deprecated*.
|
> Note that `Current.self_address` is *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let main = (p : unit) : address => Tezos.self_address;
|
let main = (p : unit) : address => Tezos.self_address;
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `Current.self_address` is *deprecated*.
|
> Note that `Current.self_address` is *deprecated*.
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Implicit Account
|
## Implicit Account
|
||||||
|
|
||||||
@ -278,9 +328,10 @@ Get the default contract associated with an on-chain key-pair. This
|
|||||||
contract does not execute code, instead it exists to receive tokens on
|
contract does not execute code, instead it exists to receive tokens on
|
||||||
behalf of a key's owner.
|
behalf of a key's owner.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function main (const kh: key_hash) : contract (unit) is
|
function main (const kh: key_hash) : contract (unit) is
|
||||||
Tezos.implicit_account (kh)
|
Tezos.implicit_account (kh)
|
||||||
@ -288,14 +339,18 @@ function main (const kh: key_hash) : contract (unit) is
|
|||||||
|
|
||||||
> Note that `implicit_account` is *deprecated*.
|
> Note that `implicit_account` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let main (kh : key_hash) : unit contract = Tezos.implicit_account kh
|
let main (kh : key_hash) : unit contract = Tezos.implicit_account kh
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `Current.implicit_account` is *deprecated*.
|
> Note that `Current.implicit_account` is *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let main = (kh : key_hash): contract (unit) =>
|
let main = (kh : key_hash): contract (unit) =>
|
||||||
Tezos.implicit_account (kh);
|
Tezos.implicit_account (kh);
|
||||||
@ -303,7 +358,8 @@ let main = (kh : key_hash): contract (unit) =>
|
|||||||
|
|
||||||
> Note that `Current.implicit_account` is *deprecated*.
|
> Note that `Current.implicit_account` is *deprecated*.
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Source
|
## Source
|
||||||
|
|
||||||
@ -331,29 +387,36 @@ current transaction.
|
|||||||
> tezos-client to transfer to whatever KT1 delegates they had, even
|
> tezos-client to transfer to whatever KT1 delegates they had, even
|
||||||
> if those KT1 were malicious scripts.
|
> if those KT1 were malicious scripts.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function main (const p: unit) : address is Tezos.source
|
function main (const p: unit) : address is Tezos.source
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `source` is *deprecated*.
|
> Note that `source` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let main (p : unit) : address = Tezos.source
|
let main (p : unit) : address = Tezos.source
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `Current.source` is *deprecated*.
|
> Note that `Current.source` is *deprecated*.
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let main = (p : unit) : address => Tezos.source;
|
let main = (p : unit) : address => Tezos.source;
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `Current.source` is *deprecated*.
|
> Note that `Current.source` is *deprecated*.
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Failwith
|
## Failwith
|
||||||
|
|
||||||
@ -362,9 +425,10 @@ Cause the contract to fail with an error message.
|
|||||||
> ⚠ Using this currently requires in general a type annotation on the
|
> ⚠ Using this currently requires in general a type annotation on the
|
||||||
> `failwith` call.
|
> `failwith` call.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function main (const p : int; const s : unit) : list (operation) * unit is
|
function main (const p : int; const s : unit) : list (operation) * unit is
|
||||||
block {
|
block {
|
||||||
@ -373,15 +437,20 @@ function main (const p : int; const s : unit) : list (operation) * unit is
|
|||||||
with ((nil : list (operation)), s)
|
with ((nil : list (operation)), s)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let main (p,s : int * unit) = if p > 10 then failwith "Failure."
|
let main (p,s : int * unit) = if p > 10 then failwith "Failure."
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let main = ((p,s) : (int, unit)) =>
|
let main = ((p,s) : (int, unit)) =>
|
||||||
if (p > 10) { failwith ("Failure."); };
|
if (p > 10) { failwith ("Failure."); };
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ id: list-reference
|
|||||||
title: Lists — Linear Collections
|
title: Lists — Linear Collections
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
Lists are linear collections of elements of the same type. Linear
|
Lists are linear collections of elements of the same type. Linear
|
||||||
means that, in order to reach an element in a list, we must visit all
|
means that, in order to reach an element in a list, we must visit all
|
||||||
the elements before (sequential access). Elements can be repeated, as
|
the elements before (sequential access). Elements can be repeated, as
|
||||||
@ -13,52 +15,62 @@ think of a list a *stack*, where the top is written on the left.
|
|||||||
|
|
||||||
# Defining Lists
|
# Defining Lists
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=lists
|
```pascaligo group=lists
|
||||||
const empty_list : list (int) = nil // Or list []
|
const empty_list : list (int) = nil // Or list []
|
||||||
const my_list : list (int) = list [1; 2; 2] // The head is 1
|
const my_list : list (int) = list [1; 2; 2] // The head is 1
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=lists
|
```cameligo group=lists
|
||||||
let empty_list : int list = []
|
let empty_list : int list = []
|
||||||
let my_list : int list = [1; 2; 2] // The head is 1
|
let my_list : int list = [1; 2; 2] // The head is 1
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=lists
|
```reasonligo group=lists
|
||||||
let empty_list : list (int) = [];
|
let empty_list : list (int) = [];
|
||||||
let my_list : list (int) = [1, 2, 2]; // The head is 1
|
let my_list : list (int) = [1, 2, 2]; // The head is 1
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
# Adding to Lists
|
# Adding to Lists
|
||||||
|
|
||||||
Lists can be augmented by adding an element before the head (or, in
|
Lists can be augmented by adding an element before the head (or, in
|
||||||
terms of stack, by *pushing an element on top*).
|
terms of stack, by *pushing an element on top*).
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=lists
|
```pascaligo group=lists
|
||||||
const larger_list : list (int) = 5 # my_list // [5;1;2;2]
|
const larger_list : list (int) = 5 # my_list // [5;1;2;2]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=lists
|
```cameligo group=lists
|
||||||
let larger_list : int list = 5 :: my_list // [5;1;2;2]
|
let larger_list : int list = 5 :: my_list // [5;1;2;2]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=lists
|
```reasonligo group=lists
|
||||||
let larger_list : list (int) = [5, ...my_list]; // [5,1,2,2]
|
let larger_list : list (int) = [5, ...my_list]; // [5,1,2,2]
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Functional Iteration over Lists
|
# Functional Iteration over Lists
|
||||||
@ -78,9 +90,9 @@ The first, the *iterated operation*, is an iteration over the list
|
|||||||
with a unit return value. It is useful to enforce certain invariants
|
with a unit return value. It is useful to enforce certain invariants
|
||||||
on the element of a list, or fail.
|
on the element of a list, or fail.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=lists
|
```pascaligo group=lists
|
||||||
function iter_op (const l : list (int)) : unit is
|
function iter_op (const l : list (int)) : unit is
|
||||||
@ -92,8 +104,8 @@ function iter_op (const l : list (int)) : unit is
|
|||||||
|
|
||||||
> Note that `list_iter` is *deprecated*.
|
> Note that `list_iter` is *deprecated*.
|
||||||
|
|
||||||
|
</Syntax>
|
||||||
<!--CameLIGO-->
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=lists
|
```cameligo group=lists
|
||||||
let iter_op (l : int list) : unit =
|
let iter_op (l : int list) : unit =
|
||||||
@ -101,7 +113,8 @@ let iter_op (l : int list) : unit =
|
|||||||
in List.iter predicate l
|
in List.iter predicate l
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=lists
|
```reasonligo group=lists
|
||||||
let iter_op = (l : list (int)) : unit => {
|
let iter_op = (l : list (int)) : unit => {
|
||||||
@ -110,7 +123,8 @@ let iter_op = (l : list (int)) : unit => {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Mapped Operation over Lists
|
## Mapped Operation over Lists
|
||||||
|
|
||||||
@ -118,9 +132,9 @@ We may want to change all the elements of a given list by applying to
|
|||||||
them a function. This is called a *map operation*, not to be confused
|
them a function. This is called a *map operation*, not to be confused
|
||||||
with the map data structure.
|
with the map data structure.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=lists
|
```pascaligo group=lists
|
||||||
function increment (const i : int): int is i + 1
|
function increment (const i : int): int is i + 1
|
||||||
@ -131,7 +145,8 @@ const plus_one : list (int) = List.map (increment, larger_list)
|
|||||||
|
|
||||||
> Note that `list_map` is *deprecated*.
|
> Note that `list_map` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=lists
|
```cameligo group=lists
|
||||||
let increment (i : int) : int = i + 1
|
let increment (i : int) : int = i + 1
|
||||||
@ -140,7 +155,8 @@ let increment (i : int) : int = i + 1
|
|||||||
let plus_one : int list = List.map increment larger_list
|
let plus_one : int list = List.map increment larger_list
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=lists
|
```reasonligo group=lists
|
||||||
let increment = (i : int) : int => i + 1;
|
let increment = (i : int) : int => i + 1;
|
||||||
@ -148,7 +164,9 @@ let increment = (i : int) : int => i + 1;
|
|||||||
// Creates a new list with all elements incremented by 1
|
// Creates a new list with all elements incremented by 1
|
||||||
let plus_one : list (int) = List.map (increment, larger_list);
|
let plus_one : list (int) = List.map (increment, larger_list);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Folded Operation over Lists
|
## Folded Operation over Lists
|
||||||
@ -159,9 +177,9 @@ function takes two arguments: an *accumulator* and the structure
|
|||||||
enables having a partial result that becomes complete when the
|
enables having a partial result that becomes complete when the
|
||||||
traversal of the data structure is over.
|
traversal of the data structure is over.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=lists
|
```pascaligo group=lists
|
||||||
function sum (const acc : int; const i : int): int is acc + i
|
function sum (const acc : int; const i : int): int is acc + i
|
||||||
@ -170,42 +188,52 @@ const sum_of_elements : int = List.fold (sum, my_list, 0)
|
|||||||
|
|
||||||
> Note that `list_fold` is *deprecated*.
|
> Note that `list_fold` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=lists
|
```cameligo group=lists
|
||||||
let sum (acc, i: int * int) : int = acc + i
|
let sum (acc, i: int * int) : int = acc + i
|
||||||
let sum_of_elements : int = List.fold sum my_list 0
|
let sum_of_elements : int = List.fold sum my_list 0
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=lists
|
```reasonligo group=lists
|
||||||
let sum = ((result, i): (int, int)): int => result + i;
|
let sum = ((result, i): (int, int)): int => result + i;
|
||||||
let sum_of_elements : int = List.fold (sum, my_list, 0);
|
let sum_of_elements : int = List.fold (sum, my_list, 0);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
# List Length
|
# List Length
|
||||||
|
|
||||||
Get the number of elements in a list.
|
Get the number of elements in a list.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function size_of (const l : list (int)) : nat is List.length (l)
|
function size_of (const l : list (int)) : nat is List.length (l)
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `size` is *deprecated*.
|
> Note that `size` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let size_of (l : int list) : nat = List.length l
|
let size_of (l : int list) : nat = List.length l
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let size_of = (l : list (int)) : nat => List.length (l);
|
let size_of = (l : list (int)) : nat => List.length (l);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ id: map-reference
|
|||||||
title: Maps
|
title: Maps
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
*Maps* are a data structure which associate values of the same type to
|
*Maps* are a data structure which associate values of the same type to
|
||||||
values of the same type. The former are called *key* and the latter
|
values of the same type. The former are called *key* and the latter
|
||||||
*values*. Together they make up a *binding*. An additional requirement
|
*values*. Together they make up a *binding*. An additional requirement
|
||||||
@ -11,51 +13,66 @@ sense.
|
|||||||
|
|
||||||
# Declaring a Map
|
# Declaring a Map
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
type move is int * int
|
type move is int * int
|
||||||
type register is map (address, move)
|
type register is map (address, move)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
type move = int * int
|
type move = int * int
|
||||||
type register = (address, move) map
|
type register = (address, move) map
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
type move = (int, int);
|
type move = (int, int);
|
||||||
type register = map (address, move);
|
type register = map (address, move);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
# Creating an Empty Map
|
# Creating an Empty Map
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
const empty : register = map []
|
const empty : register = map []
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
let empty : register = Map.empty
|
let empty : register = Map.empty
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
let empty : register = Map.empty
|
let empty : register = Map.empty
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
# Creating a Non-empty Map
|
# Creating a Non-empty Map
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
const moves : register =
|
const moves : register =
|
||||||
map [
|
map [
|
||||||
@ -63,7 +80,9 @@ const moves : register =
|
|||||||
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) -> (0,3)]
|
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) -> (0,3)]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
let moves : register =
|
let moves : register =
|
||||||
Map.literal [
|
Map.literal [
|
||||||
@ -71,44 +90,56 @@ let moves : register =
|
|||||||
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address), (0,3))]
|
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address), (0,3))]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
let moves : register =
|
let moves : register =
|
||||||
Map.literal ([
|
Map.literal ([
|
||||||
("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address, (1,2)),
|
("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address, (1,2)),
|
||||||
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address, (0,3))]);
|
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address, (0,3))]);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
# Accessing Map Bindings
|
# Accessing Map Bindings
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
const my_balance : option (move) =
|
const my_balance : option (move) =
|
||||||
moves [("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address)]
|
moves [("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address)]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
let my_balance : move option =
|
let my_balance : move option =
|
||||||
Map.find_opt ("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) moves
|
Map.find_opt ("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) moves
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
let my_balance : option (move) =
|
let my_balance : option (move) =
|
||||||
Map.find_opt (("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address), moves);
|
Map.find_opt (("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address), moves);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
Notice how the value we read is an optional value: this is to force
|
Notice how the value we read is an optional value: this is to force
|
||||||
the reader to account for a missing key in the map. This requires
|
the reader to account for a missing key in the map. This requires
|
||||||
*pattern matching*.
|
*pattern matching*.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
function force_access (const key : address; const moves : register) : move is
|
function force_access (const key : address; const moves : register) : move is
|
||||||
case moves[key] of
|
case moves[key] of
|
||||||
@ -117,7 +148,9 @@ function force_access (const key : address; const moves : register) : move is
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
let force_access (key, moves : address * register) : move =
|
let force_access (key, moves : address * register) : move =
|
||||||
match Map.find_opt key moves with
|
match Map.find_opt key moves with
|
||||||
@ -125,7 +158,9 @@ let force_access (key, moves : address * register) : move =
|
|||||||
| None -> (failwith "No move." : move)
|
| None -> (failwith "No move." : move)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
let force_access = ((key, moves) : (address, register)) : move => {
|
let force_access = ((key, moves) : (address, register)) : move => {
|
||||||
switch (Map.find_opt (key, moves)) {
|
switch (Map.find_opt (key, moves)) {
|
||||||
@ -134,7 +169,9 @@ let force_access = ((key, moves) : (address, register)) : move => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
# Updating a Map
|
# Updating a Map
|
||||||
|
|
||||||
@ -142,8 +179,9 @@ Given a map, we may want to add a new binding, remove one, or modify
|
|||||||
one by changing the value associated to an already existing key. All
|
one by changing the value associated to an already existing key. All
|
||||||
those operations are called *updates*.
|
those operations are called *updates*.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
function assign (var m : register) : register is
|
function assign (var m : register) : register is
|
||||||
block {
|
block {
|
||||||
@ -164,7 +202,9 @@ function assignments (var m : register) : register is
|
|||||||
} with m
|
} with m
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
let assign (m : register) : register =
|
let assign (m : register) : register =
|
||||||
Map.update
|
Map.update
|
||||||
@ -181,7 +221,9 @@ let add (m : register) : register =
|
|||||||
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) (4,9) m
|
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) (4,9) m
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
let assign = (m : register) : register =>
|
let assign = (m : register) : register =>
|
||||||
Map.update
|
Map.update
|
||||||
@ -199,13 +241,15 @@ let add = (m : register) : register =>
|
|||||||
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address), (4,9), m);
|
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address), (4,9), m);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
To remove a binding from a map, we need its key.
|
To remove a binding from a map, we need its key.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
function delete (const key : address; var moves : register) : register is
|
function delete (const key : address; var moves : register) : register is
|
||||||
block {
|
block {
|
||||||
@ -213,19 +257,24 @@ function delete (const key : address; var moves : register) : register is
|
|||||||
} with moves
|
} with moves
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
let delete (key, moves : address * register) : register =
|
let delete (key, moves : address * register) : register =
|
||||||
Map.remove key moves
|
Map.remove key moves
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
let delete = ((key, moves) : (address, register)) : register =>
|
let delete = ((key, moves) : (address, register)) : register =>
|
||||||
Map.remove (key, moves);
|
Map.remove (key, moves);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Functional Iteration over Maps
|
# Functional Iteration over Maps
|
||||||
@ -246,9 +295,9 @@ no return value: its only use is to produce side-effects. This can be
|
|||||||
useful if for example you would like to check that each value inside
|
useful if for example you would like to check that each value inside
|
||||||
of a map is within a certain range, and fail with an error otherwise.
|
of a map is within a certain range, and fail with an error otherwise.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
function iter_op (const m : register) : unit is
|
function iter_op (const m : register) : unit is
|
||||||
@ -260,7 +309,8 @@ function iter_op (const m : register) : unit is
|
|||||||
|
|
||||||
> Note that `map_iter` is *deprecated*.
|
> Note that `map_iter` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
let iter_op (m : register) : unit =
|
let iter_op (m : register) : unit =
|
||||||
@ -268,7 +318,8 @@ let iter_op (m : register) : unit =
|
|||||||
in Map.iter predicate m
|
in Map.iter predicate m
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
let iter_op = (m : register) : unit => {
|
let iter_op = (m : register) : unit => {
|
||||||
@ -276,7 +327,9 @@ let iter_op = (m : register) : unit => {
|
|||||||
Map.iter (predicate, m);
|
Map.iter (predicate, m);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Map Operations over Maps
|
## Map Operations over Maps
|
||||||
|
|
||||||
@ -285,9 +338,9 @@ function. This is called a *map operation*, not to be confused with
|
|||||||
the map data structure. The predefined functional iterator
|
the map data structure. The predefined functional iterator
|
||||||
implementing the map operation over maps is called `Map.map`.
|
implementing the map operation over maps is called `Map.map`.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
function map_op (const m : register) : register is
|
function map_op (const m : register) : register is
|
||||||
@ -299,7 +352,8 @@ function map_op (const m : register) : register is
|
|||||||
|
|
||||||
> Note that `map_map` is *deprecated*.
|
> Note that `map_map` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
let map_op (m : register) : register =
|
let map_op (m : register) : register =
|
||||||
@ -307,7 +361,8 @@ let map_op (m : register) : register =
|
|||||||
in Map.map increment m
|
in Map.map increment m
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
let map_op = (m : register) : register => {
|
let map_op = (m : register) : register => {
|
||||||
@ -315,7 +370,9 @@ let map_op = (m : register) : register => {
|
|||||||
Map.map (increment, m);
|
Map.map (increment, m);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Folded Operations over Maps
|
## Folded Operations over Maps
|
||||||
|
|
||||||
@ -325,9 +382,9 @@ function takes two arguments: an *accumulator* and the structure
|
|||||||
enables having a partial result that becomes complete when the
|
enables having a partial result that becomes complete when the
|
||||||
traversal of the data structure is over.
|
traversal of the data structure is over.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
function fold_op (const m : register) : int is
|
function fold_op (const m : register) : int is
|
||||||
@ -339,14 +396,18 @@ function fold_op (const m : register) : int is
|
|||||||
|
|
||||||
> Note that `map_fold` is *deprecated*.
|
> Note that `map_fold` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
let fold_op (m : register) : register =
|
let fold_op (m : register) : register =
|
||||||
let folded = fun (i,j : int * (address * move)) -> i + j.1.1
|
let folded = fun (i,j : int * (address * move)) -> i + j.1.1
|
||||||
in Map.fold folded m 5
|
in Map.fold folded m 5
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
let fold_op = (m : register) : register => {
|
let fold_op = (m : register) : register => {
|
||||||
let folded = ((i,j): (int, (address, move))) => i + j[1][1];
|
let folded = ((i,j): (int, (address, move))) => i + j[1][1];
|
||||||
@ -354,4 +415,5 @@ let fold_op = (m : register) : register => {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ id: set-reference
|
|||||||
title: Sets — Unordered unique collection of a type
|
title: Sets — Unordered unique collection of a type
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
Sets are unordered collections of values of the same type, like lists
|
Sets are unordered collections of values of the same type, like lists
|
||||||
are ordered collections. Like the mathematical sets and lists, sets
|
are ordered collections. Like the mathematical sets and lists, sets
|
||||||
can be empty and, if not, elements of sets in LIGO are *unique*,
|
can be empty and, if not, elements of sets in LIGO are *unique*,
|
||||||
@ -10,92 +12,122 @@ whereas they can be repeated in a *list*.
|
|||||||
|
|
||||||
# Empty Sets
|
# Empty Sets
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=sets
|
```pascaligo group=sets
|
||||||
const my_set : set (int) = set []
|
const my_set : set (int) = set []
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=sets
|
```cameligo group=sets
|
||||||
let my_set : int set = Set.empty
|
let my_set : int set = Set.empty
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=sets
|
```reasonligo group=sets
|
||||||
let my_set : set (int) = Set.empty;
|
let my_set : set (int) = Set.empty;
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
# Non-empty Sets
|
# Non-empty Sets
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=sets
|
```pascaligo group=sets
|
||||||
const my_set : set (int) = set [3; 2; 2; 1]
|
const my_set : set (int) = set [3; 2; 2; 1]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=sets
|
```cameligo group=sets
|
||||||
let my_set : int set =
|
let my_set : int set =
|
||||||
Set.add 3 (Set.add 2 (Set.add 2 (Set.add 1 (Set.empty : int set))))
|
Set.add 3 (Set.add 2 (Set.add 2 (Set.add 1 (Set.empty : int set))))
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=sets
|
```reasonligo group=sets
|
||||||
let my_set : set (int) =
|
let my_set : set (int) =
|
||||||
Set.add (3, Set.add (2, Set.add (2, Set.add (1, Set.empty : set (int)))));
|
Set.add (3, Set.add (2, Set.add (2, Set.add (1, Set.empty : set (int)))));
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
# Set Membership
|
# Set Membership
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=sets
|
```pascaligo group=sets
|
||||||
const contains_3 : bool = my_set contains 3
|
const contains_3 : bool = my_set contains 3
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=sets
|
```cameligo group=sets
|
||||||
let contains_3 : bool = Set.mem 3 my_set
|
let contains_3 : bool = Set.mem 3 my_set
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=sets
|
```reasonligo group=sets
|
||||||
let contains_3 : bool = Set.mem (3, my_set);
|
let contains_3 : bool = Set.mem (3, my_set);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
# Cardinal of Sets
|
# Cardinal of Sets
|
||||||
|
|
||||||
The predefined function `Set.size` returns the number of
|
The predefined function `Set.size` returns the number of
|
||||||
elements in a given set as follows.
|
elements in a given set as follows.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=sets
|
```pascaligo group=sets
|
||||||
const cardinal : nat = Set.size (my_set)
|
const cardinal : nat = Set.size (my_set)
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that `size` is *deprecated*.
|
> Note that `size` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=sets
|
```cameligo group=sets
|
||||||
let cardinal : nat = Set.size my_set
|
let cardinal : nat = Set.size my_set
|
||||||
```
|
```
|
||||||
<!--ReasonLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=sets
|
```reasonligo group=sets
|
||||||
let cardinal : nat = Set.size (my_set);
|
let cardinal : nat = Set.size (my_set);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
# Updating Sets
|
# Updating Sets
|
||||||
|
|
||||||
There are two ways to update a set, that is to add or remove from it.
|
There are two ways to update a set, that is to add or remove from it.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
In PascaLIGO, either we create a new set from the given one, or we
|
In PascaLIGO, either we create a new set from the given one, or we
|
||||||
modify it in-place. First, let us consider the former way:
|
modify it in-place. First, let us consider the former way:
|
||||||
```pascaligo group=sets
|
```pascaligo group=sets
|
||||||
@ -118,18 +150,24 @@ function update (var s : set (int)) : set (int) is block {
|
|||||||
const new_set : set (int) = update (my_set)
|
const new_set : set (int) = update (my_set)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=sets
|
```cameligo group=sets
|
||||||
let larger_set : int set = Set.add 4 my_set
|
let larger_set : int set = Set.add 4 my_set
|
||||||
let smaller_set : int set = Set.remove 3 my_set
|
let smaller_set : int set = Set.remove 3 my_set
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=sets
|
```reasonligo group=sets
|
||||||
let larger_set : set (int) = Set.add (4, my_set);
|
let larger_set : set (int) = Set.add (4, my_set);
|
||||||
let smaller_set : set (int) = Set.remove (3, my_set);
|
let smaller_set : set (int) = Set.remove (3, my_set);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
# Functional Iteration over Sets
|
# Functional Iteration over Sets
|
||||||
|
|
||||||
@ -149,8 +187,9 @@ no return value: its only use is to produce side-effects. This can be
|
|||||||
useful if for example you would like to check that each value inside
|
useful if for example you would like to check that each value inside
|
||||||
of a map is within a certain range, and fail with an error otherwise.
|
of a map is within a certain range, and fail with an error otherwise.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=sets
|
```pascaligo group=sets
|
||||||
function iter_op (const s : set (int)) : unit is
|
function iter_op (const s : set (int)) : unit is
|
||||||
block {
|
block {
|
||||||
@ -161,21 +200,27 @@ function iter_op (const s : set (int)) : unit is
|
|||||||
|
|
||||||
> Note that `set_iter` is *deprecated*.
|
> Note that `set_iter` is *deprecated*.
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=sets
|
```cameligo group=sets
|
||||||
let iter_op (s : int set) : unit =
|
let iter_op (s : int set) : unit =
|
||||||
let predicate = fun (i : int) -> assert (i > 3)
|
let predicate = fun (i : int) -> assert (i > 3)
|
||||||
in Set.iter predicate s
|
in Set.iter predicate s
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=sets
|
```reasonligo group=sets
|
||||||
let iter_op = (s : set (int)) : unit => {
|
let iter_op = (s : set (int)) : unit => {
|
||||||
let predicate = (i : int) => assert (i > 3);
|
let predicate = (i : int) => assert (i > 3);
|
||||||
Set.iter (predicate, s);
|
Set.iter (predicate, s);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## Folded Operation
|
## Folded Operation
|
||||||
|
|
||||||
@ -185,9 +230,10 @@ function takes two arguments: an *accumulator* and the structure
|
|||||||
enables having a partial result that becomes complete when the
|
enables having a partial result that becomes complete when the
|
||||||
traversal of the data structure is over.
|
traversal of the data structure is over.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=sets
|
```pascaligo group=sets
|
||||||
function sum (const acc : int; const i : int): int is acc + i
|
function sum (const acc : int; const i : int): int is acc + i
|
||||||
const sum_of_elements : int = Set.fold (sum, my_set, 0)
|
const sum_of_elements : int = Set.fold (sum, my_set, 0)
|
||||||
@ -206,15 +252,21 @@ function loop (const s : set (int)) : int is block {
|
|||||||
} with sum
|
} with sum
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=sets
|
```cameligo group=sets
|
||||||
let sum (acc, i : int * int) : int = acc + i
|
let sum (acc, i : int * int) : int = acc + i
|
||||||
let sum_of_elements : int = Set.fold sum my_set 0
|
let sum_of_elements : int = Set.fold sum my_set 0
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=sets
|
```reasonligo group=sets
|
||||||
let sum = ((acc, i) : (int, int)) : int => acc + i;
|
let sum = ((acc, i) : (int, int)) : int => acc + i;
|
||||||
let sum_of_elements : int = Set.fold (sum, my_set, 0);
|
let sum_of_elements : int = Set.fold (sum, my_set, 0);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
@ -3,29 +3,37 @@ id: string-reference
|
|||||||
title: String — Manipulate string data
|
title: String — Manipulate string data
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Syntax from '@theme/Syntax';
|
||||||
|
|
||||||
## String.size(s: string) : nat
|
## String.size(s: string) : nat
|
||||||
|
|
||||||
Get the size of a string. [Michelson only supports ASCII strings](http://tezos.gitlab.io/whitedoc/michelson.html#constants)
|
Get the size of a string. [Michelson only supports ASCII strings](http://tezos.gitlab.io/whitedoc/michelson.html#constants)
|
||||||
so for now you can assume that each character takes one byte of storage.
|
so for now you can assume that each character takes one byte of storage.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function string_size (const s: string) : nat is size(s)
|
function string_size (const s: string) : nat is size(s)
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let size_op (s: string) : nat = String.size s
|
let size_op (s: string) : nat = String.size s
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let size_op = (s: string): nat => String.size(s);
|
let size_op = (s: string): nat => String.size(s);
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## String.length(s: string) : nat
|
## String.length(s: string) : nat
|
||||||
|
|
||||||
@ -36,20 +44,29 @@ Alias for `String.size`.
|
|||||||
Get the substring of `s` between `pos1` inclusive and `pos2` inclusive. For example
|
Get the substring of `s` between `pos1` inclusive and `pos2` inclusive. For example
|
||||||
the string "tata" given to the function below would return "at".
|
the string "tata" given to the function below would return "at".
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
<!--PascaLIGO-->
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function slice_op (const s : string) : string is string_slice(1n , 2n , s)
|
function slice_op (const s : string) : string is string_slice(1n , 2n , s)
|
||||||
```
|
```
|
||||||
<!--CameLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let slice_op (s: string) : string = String.slice 1n 2n s
|
let slice_op (s: string) : string = String.slice 1n 2n s
|
||||||
```
|
```
|
||||||
<!--ReasonLIGO-->
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let slice_op = (s: string): string => String.slice(1n, 2n, s);
|
let slice_op = (s: string): string => String.slice(1n, 2n, s);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
|
||||||
## String.sub(pos1: nat, pos2: nat, s: string) : string
|
## String.sub(pos1: nat, pos2: nat, s: string) : string
|
||||||
|
|
||||||
@ -59,21 +76,27 @@ Alias for `String.slice`.
|
|||||||
|
|
||||||
Concatenate two strings and return the result.
|
Concatenate two strings and return the result.
|
||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
|
||||||
|
|
||||||
<!--PascaLIGO-->
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
function concat_op (const s : string) : string is s ^ "toto"
|
function concat_op (const s : string) : string is s ^ "toto"
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--CameLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo
|
```cameligo
|
||||||
let concat_syntax (s: string) = s ^ "test_literal"
|
let concat_syntax (s: string) = s ^ "test_literal"
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--ReasonLIGO-->
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let concat_syntax = (s: string) => s ++ "test_literal";
|
let concat_syntax = (s: string) => s ++ "test_literal";
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
</Syntax>
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ people have spent at his shop when buying tacos.
|
|||||||
<br/>
|
<br/>
|
||||||
<img src="/img/tutorials/get-started/tezos-taco-shop-payout/get-money.svg" width="50%" />
|
<img src="/img/tutorials/get-started/tezos-taco-shop-payout/get-money.svg" width="50%" />
|
||||||
|
|
||||||
<div style="opacity: 0.7; text-align: center; font-size: 10px;">
|
<div style={{ opacity: 0.7, textAlign: 'center', fontSize: '10px' }}>
|
||||||
<div>Icons made by <a href="https://www.flaticon.com/authors/smashicons" title="Smashicons">Smashicons</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
|
<div>Icons made by <a href="https://www.flaticon.com/authors/smashicons" title="Smashicons">Smashicons</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -23,6 +23,7 @@ people have spent at his shop when buying tacos.
|
|||||||
## Analyzing the Current Contract
|
## Analyzing the Current Contract
|
||||||
|
|
||||||
### **`taco-shop.ligo`**
|
### **`taco-shop.ligo`**
|
||||||
|
|
||||||
```pascaligo group=a
|
```pascaligo group=a
|
||||||
type taco_supply is record [
|
type taco_supply is record [
|
||||||
current_stock : nat;
|
current_stock : nat;
|
||||||
@ -128,6 +129,7 @@ const operations : list (operation) = list [payoutOperation];
|
|||||||
## Finalizing the Contract
|
## Finalizing the Contract
|
||||||
|
|
||||||
### **`taco-shop.ligo`**
|
### **`taco-shop.ligo`**
|
||||||
|
|
||||||
```pascaligo group=b
|
```pascaligo group=b
|
||||||
type taco_supply is record [
|
type taco_supply is record [
|
||||||
current_stock : nat;
|
current_stock : nat;
|
||||||
@ -190,7 +192,7 @@ ligo dry-run taco-shop.ligo --syntax pascaligo --amount 1 buy_taco 1n "map [
|
|||||||
```
|
```
|
||||||
|
|
||||||
<img src="/img/tutorials/get-started/tezos-taco-shop-payout/dry-run-1.png" />
|
<img src="/img/tutorials/get-started/tezos-taco-shop-payout/dry-run-1.png" />
|
||||||
<div style="opacity: 0.7; text-align: center; font-size: 12px; margin-top:-24px;">
|
<div style={{ opacity: 0.7, textAlign: 'center', fontSize: '12px', marginTop: '-24px' }}>
|
||||||
<b>Operation(...bytes)</b> included in the output
|
<b>Operation(...bytes)</b> included in the output
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ consumers.
|
|||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
<img src="/img/tutorials/get-started/tezos-taco-shop-smart-contract/taco-stand.svg" width="50%" />
|
<img src="/img/tutorials/get-started/tezos-taco-shop-smart-contract/taco-stand.svg" width="50%" />
|
||||||
<div style="opacity: 0.7; text-align: center; font-size: 10px;">Made by <a href="https://www.flaticon.com/authors/smashicons" title="Smashicons">Smashicons</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
|
<div style={{ opacity: 0.7, textAlign: 'center', fontSize: '10px' }}>Made by <a href="https://www.flaticon.com/authors/smashicons" title="Smashicons">Smashicons</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -74,7 +74,7 @@ executable** through the installation script, as shown in the
|
|||||||
screenshot below:
|
screenshot below:
|
||||||
|
|
||||||
<img src="/img/tutorials/get-started/tezos-taco-shop-smart-contract/install-ligo.png" />
|
<img src="/img/tutorials/get-started/tezos-taco-shop-smart-contract/install-ligo.png" />
|
||||||
<div style="opacity: 0.7; text-align: center; font-size: 12px; margin-top:-24px;">Installing the <b>next</b> version of LIGO's CLI</div>
|
<div style={{ opacity: 0.7, textAlign: 'center', fontSize: '12px', marginTop: '-24px' }}>Installing the <b>next</b> version of LIGO's CLI</div>
|
||||||
|
|
||||||
## Implementing our First `main` Function
|
## Implementing our First `main` Function
|
||||||
|
|
||||||
@ -90,6 +90,7 @@ contract, but it is something to get us started and test our LIGO
|
|||||||
installation as well.
|
installation as well.
|
||||||
|
|
||||||
### `taco-shop.ligo`
|
### `taco-shop.ligo`
|
||||||
|
|
||||||
```pascaligo group=a
|
```pascaligo group=a
|
||||||
function main (const parameter : int; const contractStorage : int) :
|
function main (const parameter : int; const contractStorage : int) :
|
||||||
list (operation) * int is
|
list (operation) * int is
|
||||||
@ -150,7 +151,7 @@ ligo dry-run taco-shop.ligo --syntax pascaligo main 4 3
|
|||||||
```
|
```
|
||||||
|
|
||||||
<img src="/img/tutorials/get-started/tezos-taco-shop-smart-contract/dry-run-1.png" />
|
<img src="/img/tutorials/get-started/tezos-taco-shop-smart-contract/dry-run-1.png" />
|
||||||
<div style="opacity: 0.7; text-align: center; font-size: 12px; margin-top:-24px;">Simulating contract execution with the CLI</div>
|
<div style={{ opacity: 0.7, textAlign: 'center', fontSize: '12px', marginTop: '-24px' }}>Simulating contract execution with the CLI</div>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
@ -167,6 +168,7 @@ fields. Additionally, we will want to combine our `taco_supply` type
|
|||||||
into a map, consisting of the entire offer of Pedro's shop.
|
into a map, consisting of the entire offer of Pedro's shop.
|
||||||
|
|
||||||
**Taco shop's storage**
|
**Taco shop's storage**
|
||||||
|
|
||||||
```pascaligo group=b
|
```pascaligo group=b
|
||||||
type taco_supply is record [
|
type taco_supply is record [
|
||||||
current_stock : nat;
|
current_stock : nat;
|
||||||
@ -181,6 +183,7 @@ Next step is to update the `main` function to include
|
|||||||
`parameter` to `unit` as well to clear things up.
|
`parameter` to `unit` as well to clear things up.
|
||||||
|
|
||||||
**`taco-shop.ligo`**
|
**`taco-shop.ligo`**
|
||||||
|
|
||||||
```pascaligo group=b+
|
```pascaligo group=b+
|
||||||
type taco_supply is record [
|
type taco_supply is record [
|
||||||
current_stock : nat;
|
current_stock : nat;
|
||||||
@ -204,6 +207,7 @@ initial storage value. In our case the storage is type-checked as
|
|||||||
our storage's value will be defined as follows:
|
our storage's value will be defined as follows:
|
||||||
|
|
||||||
**Storage value**
|
**Storage value**
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
map [
|
map [
|
||||||
1n -> record [
|
1n -> record [
|
||||||
@ -221,6 +225,7 @@ map [
|
|||||||
> by their keys `1n` and `2n`.
|
> by their keys `1n` and `2n`.
|
||||||
|
|
||||||
**Dry run command with a multi-line storage value**
|
**Dry run command with a multi-line storage value**
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
ligo dry-run taco-shop.ligo --syntax pascaligo main unit "map [
|
ligo dry-run taco-shop.ligo --syntax pascaligo main unit "map [
|
||||||
1n -> record [
|
1n -> record [
|
||||||
@ -235,7 +240,7 @@ ligo dry-run taco-shop.ligo --syntax pascaligo main unit "map [
|
|||||||
```
|
```
|
||||||
|
|
||||||
<img src="/img/tutorials/get-started/tezos-taco-shop-smart-contract/dry-run-2.png" />
|
<img src="/img/tutorials/get-started/tezos-taco-shop-smart-contract/dry-run-2.png" />
|
||||||
<div style="opacity: 0.7; text-align: center; font-size: 12px; margin-top:-24px;">Dry-run with a complex storage value</div>
|
<div style={{ opacity: 0.7, textAlign: 'center', fontSize: '12px', marginTop: '-24px' }}>Dry-run with a complex storage value</div>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
@ -264,6 +269,7 @@ Let is start by customizing our contract a bit, we will:
|
|||||||
we will want to modify it
|
we will want to modify it
|
||||||
|
|
||||||
**`taco-shop.ligo`**
|
**`taco-shop.ligo`**
|
||||||
|
|
||||||
```pascaligo group=c
|
```pascaligo group=c
|
||||||
type taco_supply is record [
|
type taco_supply is record [
|
||||||
current_stock : nat;
|
current_stock : nat;
|
||||||
@ -320,7 +326,7 @@ function buy_taco (const taco_kind_index : nat; var taco_shop_storage : taco_sho
|
|||||||
```
|
```
|
||||||
|
|
||||||
<img src="/img/tutorials/get-started/tezos-taco-shop-smart-contract/dry-run-3.png" />
|
<img src="/img/tutorials/get-started/tezos-taco-shop-smart-contract/dry-run-3.png" />
|
||||||
<div style="opacity: 0.7; text-align: center; font-size: 12px; margin-top:-24px;">Stock decreases after selling a taco</div>
|
<div style={{ opacity: 0.7, textAlign: 'center', fontSize: '12px', marginTop: '-24px' }}>Stock decreases after selling a taco</div>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
@ -341,6 +347,7 @@ To make sure we get paid, we will:
|
|||||||
the payment accepted
|
the payment accepted
|
||||||
|
|
||||||
**`taco-shop.ligo`**
|
**`taco-shop.ligo`**
|
||||||
|
|
||||||
```pascaligo group=e
|
```pascaligo group=e
|
||||||
type taco_supply is record [
|
type taco_supply is record [
|
||||||
current_stock : nat;
|
current_stock : nat;
|
||||||
@ -394,14 +401,14 @@ ligo dry-run taco-shop.ligo --syntax pascaligo --amount 1 buy_taco 1n "map [
|
|||||||
|
|
||||||
** Purchasing a Taco with 1tez **
|
** Purchasing a Taco with 1tez **
|
||||||
<img src="/img/tutorials/get-started/tezos-taco-shop-smart-contract/dry-run-4.png" />
|
<img src="/img/tutorials/get-started/tezos-taco-shop-smart-contract/dry-run-4.png" />
|
||||||
<div style="opacity: 0.7; text-align: center; font-size: 12px; margin-top:-24px;">Stock decreases after selling a taco, if the right amount of tezzies is provided</div>
|
<div style={{ opacity: 0.7, textAlign: 'center', fontSize: '12px', marginTop: '-24px' }}>Stock decreases after selling a taco, if the right amount of tezzies is provided</div>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
**Attempting to Purchase a Taco with 0.7tez**
|
**Attempting to Purchase a Taco with 0.7tez**
|
||||||
<img src="/img/tutorials/get-started/tezos-taco-shop-smart-contract/dry-run-5.png" />
|
<img src="/img/tutorials/get-started/tezos-taco-shop-smart-contract/dry-run-5.png" />
|
||||||
<div style="opacity: 0.7; text-align: center; font-size: 12px;
|
<div style={{ opacity: 0.7, textAlign: 'center', fontSize: '12px',
|
||||||
margin-top:-24px;">Stock does not decrease after a purchase attempt
|
marginTop: '-24px' }}>Stock does not decrease after a purchase attempt
|
||||||
with an insufficient payment.</div>
|
with an insufficient payment.</div>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
@ -416,11 +423,13 @@ If you would like to accept tips in your contract, simply change the
|
|||||||
following line, depending on your preference.
|
following line, depending on your preference.
|
||||||
|
|
||||||
**Without tips**
|
**Without tips**
|
||||||
|
|
||||||
```pascaligo skip
|
```pascaligo skip
|
||||||
if amount =/= current_purchase_price then
|
if amount =/= current_purchase_price then
|
||||||
```
|
```
|
||||||
|
|
||||||
**With tips**
|
**With tips**
|
||||||
|
|
||||||
```pascaligo skip
|
```pascaligo skip
|
||||||
if amount >= current_purchase_price then
|
if amount >= current_purchase_price then
|
||||||
```
|
```
|
||||||
|
20
gitlab-pages/website/.gitignore
vendored
Normal file
20
gitlab-pages/website/.gitignore
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
|
||||||
|
# generated files
|
||||||
|
.docusaurus
|
||||||
|
.cache-loader
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
@ -1,8 +1,12 @@
|
|||||||
const React = require('react');
|
import React from 'react';
|
||||||
|
import Highlight, { defaultProps } from "prism-react-renderer";
|
||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
import useThemeContext from '@theme/hooks/useThemeContext';
|
||||||
|
import defaultTheme from 'prism-react-renderer/themes/palenight';
|
||||||
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||||
|
|
||||||
const pre = '```';
|
const PASCALIGO_EXAMPLE = `
|
||||||
|
|
||||||
const PASCALIGO_EXAMPLE = `${pre}pascaligo
|
|
||||||
type storage is int
|
type storage is int
|
||||||
|
|
||||||
type parameter is
|
type parameter is
|
||||||
@ -14,8 +18,11 @@ type return is list (operation) * storage
|
|||||||
|
|
||||||
// Two entrypoints
|
// Two entrypoints
|
||||||
|
|
||||||
function add (const store : storage; const delta : int) : storage is store + delta
|
function add (const store : storage; const delta : int) : storage is
|
||||||
function sub (const store : storage; const delta : int) : storage is store - delta
|
store + delta
|
||||||
|
|
||||||
|
function sub (const store : storage; const delta : int) : storage is
|
||||||
|
store - delta
|
||||||
|
|
||||||
(* Main access point that dispatches to the entrypoints according to
|
(* Main access point that dispatches to the entrypoints according to
|
||||||
the smart contract parameter. *)
|
the smart contract parameter. *)
|
||||||
@ -27,9 +34,9 @@ function main (const action : parameter; const store : storage) : return is
|
|||||||
| Decrement (n) -> sub (store, n)
|
| Decrement (n) -> sub (store, n)
|
||||||
| Reset -> 0
|
| Reset -> 0
|
||||||
end)
|
end)
|
||||||
${pre}`;
|
`;
|
||||||
|
|
||||||
const CAMELIGO_EXAMPLE = `${pre}ocaml
|
const CAMELIGO_EXAMPLE = `
|
||||||
type storage = int
|
type storage = int
|
||||||
|
|
||||||
type parameter =
|
type parameter =
|
||||||
@ -53,10 +60,10 @@ let main (action, store : parameter * storage) : return =
|
|||||||
Increment (n) -> add (store, n)
|
Increment (n) -> add (store, n)
|
||||||
| Decrement (n) -> sub (store, n)
|
| Decrement (n) -> sub (store, n)
|
||||||
| Reset -> 0)
|
| Reset -> 0)
|
||||||
${pre}`;
|
`;
|
||||||
|
|
||||||
|
|
||||||
const REASONLIGO_EXAMPLE = `${pre}reasonligo
|
const REASONLIGO_EXAMPLE = `
|
||||||
type storage = int;
|
type storage = int;
|
||||||
|
|
||||||
type parameter =
|
type parameter =
|
||||||
@ -81,40 +88,82 @@ let main = ((action, store) : (parameter, storage)) : return => {
|
|||||||
| Decrement (n) => sub ((store, n))
|
| Decrement (n) => sub ((store, n))
|
||||||
| Reset => 0}))
|
| Reset => 0}))
|
||||||
};
|
};
|
||||||
${pre}`;
|
`;
|
||||||
|
|
||||||
|
|
||||||
module.exports = props => {
|
function CodeExamples (props) {
|
||||||
const MarkdownBlock = props.MarkdownBlock;
|
const {
|
||||||
|
siteConfig: {
|
||||||
|
themeConfig: {prism = {}},
|
||||||
|
},
|
||||||
|
} = useDocusaurusContext();
|
||||||
|
const {isDarkTheme} = useThemeContext();
|
||||||
|
const lightModeTheme = prism.theme || defaultTheme;
|
||||||
|
const darkModeTheme = prism.darkTheme || lightModeTheme;
|
||||||
|
const prismTheme = isDarkTheme ? darkModeTheme : lightModeTheme;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="tabs">
|
|
||||||
<div className="nav-tabs">
|
<Tabs
|
||||||
<div
|
defaultValue="pascaligo"
|
||||||
className="nav-link active"
|
values={[
|
||||||
data-group="examples"
|
{ label: 'PascaLIGO', value: 'pascaligo', },
|
||||||
data-tab="pascaligo"
|
{ label: 'CameLIGO', value: 'cameligo', },
|
||||||
>
|
{ label: 'ReasonLIGO', value: 'reasonligo', },
|
||||||
PascaLIGO
|
]
|
||||||
</div>
|
}>
|
||||||
<div className="nav-link" data-group="examples" data-tab="cameligo">
|
<TabItem value="pascaligo">
|
||||||
CameLIGO
|
<Highlight {...defaultProps} language="pascaligo" code={PASCALIGO_EXAMPLE} theme={prismTheme}>
|
||||||
</div>
|
{({ className, style, tokens, getLineProps, getTokenProps }) => (
|
||||||
<div className="nav-link" data-group="examples" data-tab="reasonligo">
|
<pre className={className} style={style}>
|
||||||
ReasonLIGO
|
{tokens.map((line, i) => (
|
||||||
</div>
|
<div {...getLineProps({ line, key: i })}>
|
||||||
</div>
|
{line.map((token, key) => (
|
||||||
<div className="tab-content">
|
<span {...getTokenProps({ token, key })} />
|
||||||
<div id="pascaligo" className="tab-pane active" data-group="examples">
|
))}
|
||||||
<MarkdownBlock>{PASCALIGO_EXAMPLE}</MarkdownBlock>
|
</div>
|
||||||
</div>
|
))}
|
||||||
<div id="cameligo" className="tab-pane" data-group="examples">
|
</pre>
|
||||||
<MarkdownBlock>{CAMELIGO_EXAMPLE}</MarkdownBlock>
|
)}
|
||||||
</div>
|
</Highlight>
|
||||||
<div id="reasonligo" className="tab-pane" data-group="examples">
|
</TabItem>
|
||||||
<MarkdownBlock>{REASONLIGO_EXAMPLE}</MarkdownBlock>
|
<TabItem value="cameligo">
|
||||||
</div>
|
|
||||||
</div>
|
<Highlight {...defaultProps} language="cameligo" code={CAMELIGO_EXAMPLE} theme={prismTheme}>
|
||||||
</div>
|
{({ className, style, tokens, getLineProps, getTokenProps }) => (
|
||||||
|
<pre className={className} style={style}>
|
||||||
|
{tokens.map((line, i) => (
|
||||||
|
<div {...getLineProps({ line, key: i })}>
|
||||||
|
{line.map((token, key) => (
|
||||||
|
<span {...getTokenProps({ token, key })} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</pre>
|
||||||
|
)}
|
||||||
|
</Highlight>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value="reasonligo">
|
||||||
|
|
||||||
|
<Highlight {...defaultProps} language="reasonligo" code={REASONLIGO_EXAMPLE} theme={prismTheme}>
|
||||||
|
{({ className, style, tokens, getLineProps, getTokenProps }) => (
|
||||||
|
<pre className={className} style={style}>
|
||||||
|
{tokens.map((line, i) => (
|
||||||
|
<div {...getLineProps({ line, key: i })}>
|
||||||
|
{line.map((token, key) => (
|
||||||
|
<span {...getTokenProps({ token, key })} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</pre>
|
||||||
|
)}
|
||||||
|
</Highlight>
|
||||||
|
</TabItem>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</Tabs>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default CodeExamples
|
@ -1,3 +1,5 @@
|
|||||||
|
// deprecated.
|
||||||
|
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const docUrl = require(`${process.cwd()}/core/UrlUtils`).docUrl;
|
const docUrl = require(`${process.cwd()}/core/UrlUtils`).docUrl;
|
||||||
|
|
||||||
|
226
gitlab-pages/website/docusaurus.config.js
Normal file
226
gitlab-pages/website/docusaurus.config.js
Normal file
@ -0,0 +1,226 @@
|
|||||||
|
|
||||||
|
const repoUrl = 'https://gitlab.com/ligolang/ligo';
|
||||||
|
|
||||||
|
// let reasonHighlightJs = require('reason-highlightjs');
|
||||||
|
|
||||||
|
const siteConfig = {
|
||||||
|
title: 'LIGO', // Title for your website.
|
||||||
|
tagline: 'LIGO is a friendly smart contract language for Tezos',
|
||||||
|
// taglineSub: 'Michelson was never so easy',
|
||||||
|
url: 'https://ligolang.org', // Your website URL
|
||||||
|
baseUrl: '/', // Base URL for your project */
|
||||||
|
// For github.io type URLs, you would set the url and baseUrl like:
|
||||||
|
// url: 'https://facebook.github.io',
|
||||||
|
// baseUrl: '/test-site/',
|
||||||
|
|
||||||
|
// Used for publishing and more
|
||||||
|
projectName: 'ligo',
|
||||||
|
organizationName: 'TBN',
|
||||||
|
// For top-level user or org sites, the organization is still the same.
|
||||||
|
// e.g., for the https://JoelMarcey.github.io site, it would be set like...
|
||||||
|
// organizationName: 'JoelMarcey'
|
||||||
|
|
||||||
|
// For no header links in the top nav bar -> headerLinks: [],
|
||||||
|
|
||||||
|
|
||||||
|
// footerLinks: {
|
||||||
|
// docs: [
|
||||||
|
// { doc: 'intro/installation', label: 'Install' },
|
||||||
|
// { doc: 'api/cli-commands', label: 'CLI Commands' },
|
||||||
|
// { doc: 'contributors/origin', label: 'Contribute' },
|
||||||
|
// { href: '/odoc', label: 'API Documentation' }
|
||||||
|
// ],
|
||||||
|
// community: [
|
||||||
|
// {
|
||||||
|
// href: 'https://forum.tezosagora.org/tag/ligo',
|
||||||
|
// label: 'Tezos Agora Forum',
|
||||||
|
// blankTarget: true
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// href: 'https://tezos.stackexchange.com/questions/tagged/ligo',
|
||||||
|
// label: 'Tezos Stack Exchange',
|
||||||
|
// blankTarget: true
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// href: 'https://t.me/LigoLang',
|
||||||
|
// label: 'Telegram',
|
||||||
|
// blankTarget: true
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// href: 'https://discord.gg/9rhYaEt',
|
||||||
|
// label: 'Discord',
|
||||||
|
// blankTarget: true
|
||||||
|
// }
|
||||||
|
// ],
|
||||||
|
// more: [
|
||||||
|
// {
|
||||||
|
// doc: 'tutorials/get-started/tezos-taco-shop-smart-contract',
|
||||||
|
// label: 'Tutorials'
|
||||||
|
// },
|
||||||
|
// { href: repoUrl, label: 'GitLab' }
|
||||||
|
// ]
|
||||||
|
// },
|
||||||
|
|
||||||
|
favicon: 'img/circle.svg',
|
||||||
|
|
||||||
|
/* highlight: {
|
||||||
|
// Highlight.js theme to use for syntax highlighting in code blocks.
|
||||||
|
theme: 'default',
|
||||||
|
hljs: function (hljs) {
|
||||||
|
hljs.registerLanguage('reasonligo', reasonHighlightJs);
|
||||||
|
hljs.registerLanguage('pascaligo', function (hljs) {
|
||||||
|
return {
|
||||||
|
// case_insensitive: true,
|
||||||
|
beginKeywords: '',
|
||||||
|
keywords: {
|
||||||
|
keyword:
|
||||||
|
'and attributes begin big_map block case const contains else'
|
||||||
|
+ ' end False for from function if in is list map mod nil'
|
||||||
|
+ ' not of or patch record remove set skip then to True type'
|
||||||
|
+ ' var while with',
|
||||||
|
literal: 'true false unit int string Some None bool nat list'
|
||||||
|
},
|
||||||
|
lexemes: '[a-zA-Z][a-zA-Z0-9_]*',
|
||||||
|
contains: [
|
||||||
|
hljs.C_LINE_COMMENT_MODE,
|
||||||
|
|
||||||
|
{
|
||||||
|
className: 'type',
|
||||||
|
begin: /[A-Z][a-z]+/
|
||||||
|
},
|
||||||
|
{
|
||||||
|
begin: /[*+-:;\(\)\{\}|\>\<]/
|
||||||
|
// className: 'ignore'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},*/
|
||||||
|
|
||||||
|
// Add custom scripts here that would be placed in <script> tags.
|
||||||
|
scripts: ['https://buttons.github.io/buttons.js'],
|
||||||
|
|
||||||
|
// On page navigation for the current documentation page.
|
||||||
|
// No .html extensions for paths.
|
||||||
|
|
||||||
|
// Show documentation's last contributor's name.
|
||||||
|
// enableUpdateBy: true,
|
||||||
|
|
||||||
|
// Show documentation's last update time.
|
||||||
|
// enableUpdateTime: true,
|
||||||
|
|
||||||
|
// You may provide arbitrary config keys to be used as needed by your
|
||||||
|
// template. For example, if you need your repo's URL...
|
||||||
|
// repoUrl: repoUrl,
|
||||||
|
stylesheets: [
|
||||||
|
'https://fonts.googleapis.com/css?family=DM+Sans:400,400i,500,500i,700,700i|Open+Sans:300,300i,400,600|Source+Code+Pro&display=swap'
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
'@docusaurus/preset-classic',
|
||||||
|
{
|
||||||
|
docs: {
|
||||||
|
// docs folder path relative to website dir.
|
||||||
|
path: '../docs',
|
||||||
|
// sidebars file relative to website dir.
|
||||||
|
sidebarPath: require.resolve('./sidebars.json'),
|
||||||
|
},
|
||||||
|
theme: {
|
||||||
|
customCss: require.resolve('./static/css/custom.css'),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
themeConfig: {
|
||||||
|
googleAnalytics: {
|
||||||
|
trackingID: 'UA-153751765-1',
|
||||||
|
gtag: true
|
||||||
|
},
|
||||||
|
algolia: {
|
||||||
|
apiKey: '12be98d9fd4242a5f16b70a5cc6b0158',
|
||||||
|
indexName: 'ligolang',
|
||||||
|
algoliaOptions: {} // Optional, if provided by Algolia
|
||||||
|
},
|
||||||
|
navbar: {
|
||||||
|
logo: {
|
||||||
|
alt: 'LIGO Logo',
|
||||||
|
src: 'img/logo.svg',
|
||||||
|
srcDark: 'img/logo-night.svg'
|
||||||
|
},
|
||||||
|
links: [
|
||||||
|
{ href: 'https://ide.ligolang.org/', label: 'Try Online' },
|
||||||
|
{ to: 'docs/intro/installation', label: 'Install' },
|
||||||
|
{ to: 'docs/intro/what-and-why', label: 'Docs' },
|
||||||
|
{
|
||||||
|
to: 'docs/tutorials/get-started/tezos-taco-shop-smart-contract',
|
||||||
|
label: 'Tutorials'
|
||||||
|
},
|
||||||
|
{ href: 'https://forum.tezosagora.org/tag/ligo', label: 'Blog' },
|
||||||
|
// TODO: { href: "/odoc", label: "API" },
|
||||||
|
// { doc: 'contributors/origin', label: 'Contribute' },
|
||||||
|
{ to: '/contact', label: 'Ask Questions' }
|
||||||
|
],
|
||||||
|
},
|
||||||
|
footer: {
|
||||||
|
links: [
|
||||||
|
{
|
||||||
|
title: 'Docs',
|
||||||
|
items: [
|
||||||
|
{ to: 'docs/intro/installation', label: 'Install' },
|
||||||
|
{ to: 'docs/api/cli-commands', label: 'CLI Commands' },
|
||||||
|
{ to: 'docs/contributors/origin', label: 'Contribute' },
|
||||||
|
{ to: '/odoc', label: 'API Documentation' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Community',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
href: 'https://forum.tezosagora.org/tag/ligo',
|
||||||
|
label: 'Tezos Agora Forum'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: 'https://tezos.stackexchange.com/questions/tagged/ligo',
|
||||||
|
label: 'Tezos Stack Exchange'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: 'https://t.me/LigoLang',
|
||||||
|
label: 'Telegram'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: 'https://discord.gg/9rhYaEt',
|
||||||
|
label: 'Discord'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'More',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
label: 'Tutorials',
|
||||||
|
to: 'docs/tutorials/get-started/tezos-taco-shop-smart-contract'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'GitLab',
|
||||||
|
href: repoUrl
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// { href: 'https://ide.ligolang.org/', title: 'Try Online' }
|
||||||
|
],
|
||||||
|
copyright: `© ${new Date().getFullYear()} LIGO. All rights reserved.`,
|
||||||
|
},
|
||||||
|
image: 'img/docusaurus.png',
|
||||||
|
sidebarCollapsible: true,
|
||||||
|
prism: {
|
||||||
|
theme: require('prism-react-renderer/themes/github'),
|
||||||
|
darkTheme: require('prism-react-renderer/themes/vsDark')
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = siteConfig;
|
@ -1,17 +1,24 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"examples": "docusaurus-examples",
|
"start": "docusaurus start --host 0.0.0.0 --port 3000",
|
||||||
"start": "docusaurus-start",
|
"build": "docusaurus build",
|
||||||
"build": "docusaurus-build",
|
"swizzle": "docusaurus swizzle",
|
||||||
"publish-gh-pages": "docusaurus-publish",
|
"deploy": "docusaurus deploy"
|
||||||
"write-translations": "docusaurus-write-translations",
|
|
||||||
"version": "docusaurus-version",
|
|
||||||
"preversion": "node preversion.js",
|
|
||||||
"postversion": "node postversion.js",
|
|
||||||
"rename-version": "docusaurus-rename-version"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"docusaurus": "^1.14.0",
|
"@docusaurus/core": "^2.0.0-alpha.43",
|
||||||
"reason-highlightjs": "0.2.1"
|
"@docusaurus/preset-classic": "^2.0.0-alpha.43",
|
||||||
|
"classnames": "^2.2.6",
|
||||||
|
"react": "^16.13.0",
|
||||||
|
"react-dom": "^16.13.0",
|
||||||
|
"webpack": "4.41.2"
|
||||||
|
},
|
||||||
|
"browserslist": {
|
||||||
|
"production": [">0.2%", "not dead", "not op_mini all"],
|
||||||
|
"development": [
|
||||||
|
"last 1 chrome version",
|
||||||
|
"last 1 firefox version",
|
||||||
|
"last 1 safari version"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,100 +0,0 @@
|
|||||||
const React = require('react');
|
|
||||||
const MarkdownBlock = require('../../core/CompLibrary').MarkdownBlock;
|
|
||||||
const CodeExamples = require(`${process.cwd()}/core/CodeExamples`);
|
|
||||||
const docUrl = require(`${process.cwd()}/core/UrlUtils`).docUrl;
|
|
||||||
|
|
||||||
const FEATURES = [
|
|
||||||
{
|
|
||||||
image: 'img/strong-type-system.svg',
|
|
||||||
title: 'Strong, Static Type System',
|
|
||||||
content: 'Write types, then code. Benefit from the safety of type systems.'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
image: 'img/syntax-agnostic.svg',
|
|
||||||
title: 'Polyglot',
|
|
||||||
content:
|
|
||||||
'Code in your language. Write PascaLIGO, CameLIGO, ReasonLIGO or add your own syntax.'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
image: 'img/easy-integration.svg',
|
|
||||||
title: 'Easy Integration',
|
|
||||||
content: 'You can use LIGO as a NodeJS library with Granary'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
const PARTNERS = [
|
|
||||||
{
|
|
||||||
name: 'Nomadic Labs',
|
|
||||||
image: 'img/nomadic-logo.png',
|
|
||||||
link: 'https://www.nomadic-labs.com/',
|
|
||||||
pinned: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Tocqueville Group',
|
|
||||||
image: 'img/tq-logo.svg',
|
|
||||||
link: 'https://tqgroup.io/',
|
|
||||||
pinned: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Stove Labs',
|
|
||||||
image: 'img/stove-logo.png',
|
|
||||||
link: 'https://stove-labs.com',
|
|
||||||
pinned: true
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
const Feature = (config, props) => (
|
|
||||||
<div className="feature" key={props.title}>
|
|
||||||
<img src={`${config.baseUrl}${props.image}`} />
|
|
||||||
<h1>{props.title}</h1>
|
|
||||||
<p>{props.content}</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
const Partner = (config, props) => (
|
|
||||||
<a
|
|
||||||
href={props.link}
|
|
||||||
title={props.name}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
<img src={`${config.baseUrl}${props.image}`} />
|
|
||||||
</a>
|
|
||||||
);
|
|
||||||
|
|
||||||
module.exports = props => {
|
|
||||||
return (
|
|
||||||
<div id="homePage">
|
|
||||||
<div id="intro" className="centered">
|
|
||||||
<div id="callToAction">
|
|
||||||
<ul>
|
|
||||||
<li className="primary">
|
|
||||||
<a href="https://ide.ligolang.org">Try Online</a>
|
|
||||||
</li>
|
|
||||||
<li className="secondary">
|
|
||||||
<a href={docUrl(props.config, 'intro/installation')}>Install</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div id="preview">
|
|
||||||
<h1>A friendly Smart Contract Language for Tezos</h1>
|
|
||||||
<p>Michelson was never so easy</p>
|
|
||||||
<CodeExamples MarkdownBlock={MarkdownBlock}></CodeExamples>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="features" className="centered">
|
|
||||||
{FEATURES.map(entry => Feature(props.config, entry))}
|
|
||||||
</div>
|
|
||||||
<div id="partners">
|
|
||||||
<div className="centered wrapper">
|
|
||||||
<span id="heading">Our Partners</span>
|
|
||||||
<div id="list">
|
|
||||||
{PARTNERS.filter(entry => entry.pinned).map(entry =>
|
|
||||||
Partner(props.config, entry)
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
@ -1,113 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2017-present, Facebook, Inc.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
const React = require('react');
|
|
||||||
|
|
||||||
const CompLibrary = require('../../core/CompLibrary');
|
|
||||||
|
|
||||||
const Container = CompLibrary.Container;
|
|
||||||
|
|
||||||
const CWD = process.cwd();
|
|
||||||
|
|
||||||
const versions = require(`${CWD}/versions.json`);
|
|
||||||
|
|
||||||
function Versions(props) {
|
|
||||||
const {config: siteConfig} = props;
|
|
||||||
const latestVersion = versions[0];
|
|
||||||
const repoUrl = `${siteConfig.repoUrl}`;
|
|
||||||
return (
|
|
||||||
<div className="docMainWrapper wrapper">
|
|
||||||
<Container className="mainContainer versionsContainer">
|
|
||||||
<div className="post">
|
|
||||||
<header className="postHeader">
|
|
||||||
<h1>{siteConfig.title} Versions </h1>
|
|
||||||
</header>
|
|
||||||
<h3 id="latest">Current version</h3>
|
|
||||||
<table className="versions">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<th>{latestVersion}</th>
|
|
||||||
<td>
|
|
||||||
{/* You are supposed to change this href where appropriate
|
|
||||||
Example: href="<baseUrl>/docs(/:language)/:id" */}
|
|
||||||
<a
|
|
||||||
href={`${siteConfig.baseUrl}${siteConfig.docsUrl}/${
|
|
||||||
props.language ? props.language + '/' : ''
|
|
||||||
}intro/installation`}>
|
|
||||||
Documentation
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href={repoUrl}>Source Code</a>
|
|
||||||
</td>
|
|
||||||
{/* <td>
|
|
||||||
<a href="">Release Notes</a>
|
|
||||||
</td> */}
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<h3 id="rc">Pre-release versions</h3>
|
|
||||||
<table className="versions">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<th>next</th>
|
|
||||||
<td>
|
|
||||||
{/* You are supposed to change this href where appropriate
|
|
||||||
Example: href="<baseUrl>/docs(/:language)/next/:id" */}
|
|
||||||
<a
|
|
||||||
href={`${siteConfig.baseUrl}${siteConfig.docsUrl}/${
|
|
||||||
props.language ? props.language + '/' : ''
|
|
||||||
}next/intro/installation`}>
|
|
||||||
Documentation
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href={repoUrl}>Source Code</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<h3 id="archive">Past Versions</h3>
|
|
||||||
<p>Here you can find previous versions of the documentation.</p>
|
|
||||||
<table className="versions">
|
|
||||||
<tbody>
|
|
||||||
{versions.map(
|
|
||||||
version =>
|
|
||||||
version !== latestVersion && version !== "next" && (
|
|
||||||
<tr>
|
|
||||||
<th>{version}</th>
|
|
||||||
<td>
|
|
||||||
{/* You are supposed to change this href where appropriate
|
|
||||||
Example: href="<baseUrl>/docs(/:language)/:version/:id" */}
|
|
||||||
<a
|
|
||||||
href={`${siteConfig.baseUrl}${siteConfig.docsUrl}/${
|
|
||||||
props.language ? props.language + '/' : ''
|
|
||||||
}${version}/intro/installation`}>
|
|
||||||
Documentation
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href={`${repoUrl}/releases/tag/v${version}`}>
|
|
||||||
Release Notes
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
),
|
|
||||||
)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<p>
|
|
||||||
You can find past versions of this project on{' '}
|
|
||||||
<a href={repoUrl}>GitLab</a>.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</Container>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = Versions;
|
|
@ -1,158 +0,0 @@
|
|||||||
const repoUrl = 'https://gitlab.com/ligolang/ligo';
|
|
||||||
|
|
||||||
let reasonHighlightJs = require('reason-highlightjs');
|
|
||||||
|
|
||||||
const siteConfig = {
|
|
||||||
title: 'LIGO', // Title for your website.
|
|
||||||
tagline: 'LIGO is a friendly smart contract language for Tezos',
|
|
||||||
taglineSub: 'Michelson was never so easy',
|
|
||||||
url: 'https://ligolang.org', // Your website URL
|
|
||||||
baseUrl: '/', // Base URL for your project */
|
|
||||||
// For github.io type URLs, you would set the url and baseUrl like:
|
|
||||||
// url: 'https://facebook.github.io',
|
|
||||||
// baseUrl: '/test-site/',
|
|
||||||
|
|
||||||
// Used for publishing and more
|
|
||||||
projectName: 'ligo',
|
|
||||||
organizationName: 'TBN',
|
|
||||||
// For top-level user or org sites, the organization is still the same.
|
|
||||||
// e.g., for the https://JoelMarcey.github.io site, it would be set like...
|
|
||||||
// organizationName: 'JoelMarcey'
|
|
||||||
|
|
||||||
// For no header links in the top nav bar -> headerLinks: [],
|
|
||||||
headerLinks: [
|
|
||||||
{ href: 'https://ide.ligolang.org/', label: 'Try Online' },
|
|
||||||
{ doc: 'intro/installation', label: 'Install' },
|
|
||||||
{ doc: 'intro/what-and-why', label: 'Docs' },
|
|
||||||
{
|
|
||||||
doc: 'tutorials/get-started/tezos-taco-shop-smart-contract',
|
|
||||||
label: 'Tutorials'
|
|
||||||
},
|
|
||||||
{ blog: true, label: 'Blog' },
|
|
||||||
// TODO: { href: "/odoc", label: "API" },
|
|
||||||
// { doc: 'contributors/origin', label: 'Contribute' },
|
|
||||||
{ href: '/contact', label: 'Ask Questions' },
|
|
||||||
{ search: true }
|
|
||||||
],
|
|
||||||
|
|
||||||
footerLinks: {
|
|
||||||
docs: [
|
|
||||||
{ doc: 'intro/installation', label: 'Install' },
|
|
||||||
{ doc: 'api/cli-commands', label: 'CLI Commands' },
|
|
||||||
{ doc: 'contributors/origin', label: 'Contribute' },
|
|
||||||
{ href: '/odoc', label: 'API Documentation' }
|
|
||||||
],
|
|
||||||
community: [
|
|
||||||
{
|
|
||||||
href: 'https://forum.tezosagora.org/tag/ligo',
|
|
||||||
label: 'Tezos Agora Forum',
|
|
||||||
blankTarget: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: 'https://tezos.stackexchange.com/questions/tagged/ligo',
|
|
||||||
label: 'Tezos Stack Exchange',
|
|
||||||
blankTarget: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: 'https://t.me/LigoLang',
|
|
||||||
label: 'Telegram',
|
|
||||||
blankTarget: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: 'https://discord.gg/9rhYaEt',
|
|
||||||
label: 'Discord',
|
|
||||||
blankTarget: true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
more: [
|
|
||||||
{
|
|
||||||
doc: 'tutorials/get-started/tezos-taco-shop-smart-contract',
|
|
||||||
label: 'Tutorials'
|
|
||||||
},
|
|
||||||
{ href: repoUrl, label: 'GitLab' }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
/* path to images for header/footer */
|
|
||||||
footerIcon: 'img/logo.svg',
|
|
||||||
favicon: 'img/logo.svg',
|
|
||||||
|
|
||||||
/* Colors for website */
|
|
||||||
colors: {
|
|
||||||
primaryColor: '#1A1A1A',
|
|
||||||
secondaryColor: '#1A1A1A'
|
|
||||||
},
|
|
||||||
|
|
||||||
// This copyright info is used in /core/Footer.js and blog RSS/Atom feeds.
|
|
||||||
copyright: `© ${new Date().getFullYear()} LIGO. All rights reserved.`,
|
|
||||||
|
|
||||||
highlight: {
|
|
||||||
// Highlight.js theme to use for syntax highlighting in code blocks.
|
|
||||||
theme: 'default',
|
|
||||||
hljs: function (hljs) {
|
|
||||||
hljs.registerLanguage('reasonligo', reasonHighlightJs);
|
|
||||||
hljs.registerLanguage('pascaligo', function (hljs) {
|
|
||||||
return {
|
|
||||||
// case_insensitive: true,
|
|
||||||
beginKeywords: '',
|
|
||||||
keywords: {
|
|
||||||
keyword:
|
|
||||||
'and attributes begin big_map block case const contains else'
|
|
||||||
+ ' end False for from function if in is list map mod nil'
|
|
||||||
+ ' not of or patch record remove set skip then to True type'
|
|
||||||
+ ' var while with',
|
|
||||||
literal: 'true false unit int string Some None bool nat list'
|
|
||||||
},
|
|
||||||
lexemes: '[a-zA-Z][a-zA-Z0-9_]*',
|
|
||||||
contains: [
|
|
||||||
hljs.C_LINE_COMMENT_MODE,
|
|
||||||
|
|
||||||
{
|
|
||||||
className: 'type',
|
|
||||||
begin: /[A-Z][a-z]+/
|
|
||||||
},
|
|
||||||
{
|
|
||||||
begin: /[*+-:;\(\)\{\}|\>\<]/
|
|
||||||
// className: 'ignore'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Add custom scripts here that would be placed in <script> tags.
|
|
||||||
scripts: ['https://buttons.github.io/buttons.js'],
|
|
||||||
|
|
||||||
// On page navigation for the current documentation page.
|
|
||||||
onPageNav: 'separate',
|
|
||||||
// No .html extensions for paths.
|
|
||||||
cleanUrl: true,
|
|
||||||
|
|
||||||
// Open Graph and Twitter card images.
|
|
||||||
ogImage: 'img/logo.svg',
|
|
||||||
twitterImage: 'img/undraw_tweetstorm.svg',
|
|
||||||
|
|
||||||
// Show documentation's last contributor's name.
|
|
||||||
// enableUpdateBy: true,
|
|
||||||
|
|
||||||
// Show documentation's last update time.
|
|
||||||
// enableUpdateTime: true,
|
|
||||||
|
|
||||||
// You may provide arbitrary config keys to be used as needed by your
|
|
||||||
// template. For example, if you need your repo's URL...
|
|
||||||
repoUrl: repoUrl,
|
|
||||||
stylesheets: [
|
|
||||||
'https://fonts.googleapis.com/css?family=DM+Sans:400,400i,500,500i,700,700i|Open+Sans:300,300i,400,600|Source+Code+Pro&display=swap'
|
|
||||||
],
|
|
||||||
algolia: {
|
|
||||||
apiKey: '12be98d9fd4242a5f16b70a5cc6b0158',
|
|
||||||
indexName: 'ligolang',
|
|
||||||
algoliaOptions: {} // Optional, if provided by Algolia
|
|
||||||
},
|
|
||||||
docsSideNavCollapsible: true,
|
|
||||||
gaTrackingId: 'UA-153751765-1',
|
|
||||||
gaGtag: true
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = siteConfig;
|
|
@ -1,4 +1,6 @@
|
|||||||
const React = require('react');
|
import React from 'react';
|
||||||
|
import Layout from '@theme/Layout';
|
||||||
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||||
|
|
||||||
const TEAM = [
|
const TEAM = [
|
||||||
{
|
{
|
||||||
@ -49,7 +51,7 @@ const COMMUNICATION_CHANNELS = [
|
|||||||
{
|
{
|
||||||
link: 'https://t.me/LigoLang',
|
link: 'https://t.me/LigoLang',
|
||||||
icon: 'img/telegram.svg',
|
icon: 'img/telegram.svg',
|
||||||
description: "We're hear to help. Ask us anything"
|
description: "We're here to help. Ask us anything"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
link: 'https://gitlab.com/ligolang/ligo/issues',
|
link: 'https://gitlab.com/ligolang/ligo/issues',
|
||||||
@ -72,7 +74,7 @@ const Portrait = (config, props) => {
|
|||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
<img className="portrait" src={`${config.baseUrl}${props.image}`} />
|
<img className="portrait" src={useBaseUrl(props.image)} />
|
||||||
<div className="overlay">
|
<div className="overlay">
|
||||||
<span>{props.firstName}</span>
|
<span>{props.firstName}</span>
|
||||||
<span>{props.lastName}</span>
|
<span>{props.lastName}</span>
|
||||||
@ -89,36 +91,44 @@ const CommunicationChannel = (config, props) => {
|
|||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
<img className="icon" src={`${config.baseUrl}${props.icon}`} />
|
<img className="icon" src={useBaseUrl(props.icon)} />
|
||||||
{props.description}
|
{props.description}
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = props => {
|
export default props => {
|
||||||
const pinnedMembers = TEAM.filter(member => member.pinned);
|
const pinnedMembers = TEAM.filter(member => member.pinned);
|
||||||
const membersCeilCount = Math.ceil(pinnedMembers.length / 2);
|
const membersCeilCount = Math.ceil(pinnedMembers.length / 2);
|
||||||
const membersInFistColumn = pinnedMembers.slice(0, membersCeilCount);
|
const membersInFistColumn = pinnedMembers.slice(0, membersCeilCount);
|
||||||
const membersInSecondColumn = pinnedMembers.slice(membersCeilCount);
|
const membersInSecondColumn = pinnedMembers.slice(membersCeilCount);
|
||||||
|
return <Layout title="Contact">
|
||||||
return (
|
<div
|
||||||
<div id="contactPage" className="centered">
|
id="contactPage"
|
||||||
<div id="mural">
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'stretch',
|
||||||
|
alignItems: 'stretch',
|
||||||
|
fontSize: '20px',
|
||||||
|
flexDirection: 'row'
|
||||||
|
}}>
|
||||||
|
<div id="mural">
|
||||||
<div className="column">
|
<div className="column">
|
||||||
{membersInFistColumn.map(entry => Portrait(props.config, entry))}
|
{membersInFistColumn.map(entry => Portrait(props.config, entry))}
|
||||||
</div>
|
</div>
|
||||||
<div className="offset column">
|
<div className="offset column">
|
||||||
{membersInSecondColumn.map(entry => Portrait(props.config, entry))}
|
{membersInSecondColumn.map(entry => Portrait(props.config, entry))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="message">
|
<div id="message">
|
||||||
<div className="title">Talk to us</div>
|
<div className="title">Talk to us</div>
|
||||||
<div className="communicationOptions">
|
<div className="communicationOptions">
|
||||||
{COMMUNICATION_CHANNELS.map(entry =>
|
{COMMUNICATION_CHANNELS.map(entry =>
|
||||||
CommunicationChannel(props.config, entry)
|
CommunicationChannel(props.config, entry)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
</div>
|
||||||
};
|
</Layout>
|
||||||
|
}
|
||||||
|
|
184
gitlab-pages/website/src/pages/index.js
Normal file
184
gitlab-pages/website/src/pages/index.js
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import Layout from '@theme/Layout';
|
||||||
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||||
|
import CodeExamples from '../../core/CodeExamples';
|
||||||
|
const {Prism} = require("prism-react-renderer");
|
||||||
|
|
||||||
|
|
||||||
|
Prism.languages = {
|
||||||
|
...Prism.languages,
|
||||||
|
pascaligo: {
|
||||||
|
'comment': [
|
||||||
|
/\(\*[\s\S]+?\*\)/,
|
||||||
|
// /\{[\s\S]+?\}/,
|
||||||
|
/\/\/.*/
|
||||||
|
],
|
||||||
|
'string': {
|
||||||
|
pattern: /(?:'(?:''|[^'\r\n])*'|#[&$%]?[a-f\d]+)+|\^[a-z]/i,
|
||||||
|
greedy: true
|
||||||
|
},
|
||||||
|
'keyword': [
|
||||||
|
{
|
||||||
|
// Turbo Pascal
|
||||||
|
pattern: /(^|[^&])\b(?:absolute|array|asm|begin|case|const|constructor|destructor|do|downto|else|end|file|for|function|goto|if|implementation|inherited|inline|interface|label|nil|object|of|operator|packed|procedure|program|record|reintroduce|repeat|self|set|string|then|to|type|unit|until|uses|var|while|with)\b/i,
|
||||||
|
lookbehind: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Free Pascal
|
||||||
|
pattern: /(^|[^&])\b(?:dispose|exit|false|new|true)\b/i,
|
||||||
|
lookbehind: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Object Pascal
|
||||||
|
pattern: /(^|[^&])\b(?:class|dispinterface|except|exports|finalization|finally|initialization|inline|library|on|out|packed|property|raise|resourcestring|threadvar|try)\b/i,
|
||||||
|
lookbehind: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Modifiers
|
||||||
|
pattern: /(^|[^&])\b(?:absolute|abstract|alias|assembler|bitpacked|break|cdecl|continue|cppdecl|cvar|default|deprecated|dynamic|enumerator|experimental|export|external|far|far16|forward|generic|helper|implements|index|interrupt|iochecks|local|message|name|near|nodefault|noreturn|nostackframe|oldfpccall|otherwise|overload|override|pascal|platform|private|protected|public|published|read|register|reintroduce|result|safecall|saveregisters|softfloat|specialize|static|stdcall|stored|strict|unaligned|unimplemented|varargs|virtual|write)\b/i,
|
||||||
|
lookbehind: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'number': [
|
||||||
|
// Hexadecimal, octal and binary
|
||||||
|
/(?:[&%]\d+|\$[a-f\d]+)/i,
|
||||||
|
// Decimal
|
||||||
|
/\b\d+(?:\.\d+)?(?:e[+-]?\d+)?/i
|
||||||
|
],
|
||||||
|
'operator': [
|
||||||
|
/\.\.|\*\*|:=|<[<=>]?|>[>=]?|[+\-*\/]=?|[@^=]/i,
|
||||||
|
{
|
||||||
|
pattern: /(^|[^&])\b(?:and|as|div|exclude|in|include|is|mod|not|or|shl|shr|xor)\b/,
|
||||||
|
lookbehind: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'punctuation': /\(\.|\.\)|[()\[\]:;,.]/
|
||||||
|
},
|
||||||
|
reasonligo:
|
||||||
|
{...Prism.languages.reason,
|
||||||
|
'comment': [
|
||||||
|
/(^|[^\\])\/\*[\s\S]*?\*\//,
|
||||||
|
/\(\*[\s\S]*?\*\)/,
|
||||||
|
/\/\/.*/
|
||||||
|
]
|
||||||
|
|
||||||
|
},
|
||||||
|
cameligo: {
|
||||||
|
...Prism.languages.ocaml,
|
||||||
|
'comment': [
|
||||||
|
/(^|[^\\])\/\*[\s\S]*?\*\//,
|
||||||
|
/\(\*[\s\S]*?\*\)/,
|
||||||
|
/\/\/.*/
|
||||||
|
]}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const FEATURES = [
|
||||||
|
{
|
||||||
|
image: 'img/strong-type-system.svg',
|
||||||
|
title: 'Strong, Static Type System',
|
||||||
|
content: 'Write types, then code. Benefit from the safety of type systems.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
image: 'img/syntax-agnostic.svg',
|
||||||
|
title: 'Polyglot',
|
||||||
|
content:
|
||||||
|
'Code in your language. Write PascaLIGO, CameLIGO, ReasonLIGO or add your own syntax.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
image: 'img/easy-integration.svg',
|
||||||
|
title: 'Easy Integration',
|
||||||
|
content: 'You can use LIGO as a NodeJS library with Granary'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const PARTNERS = [
|
||||||
|
{
|
||||||
|
name: 'Nomadic Labs',
|
||||||
|
image: 'img/nomadic-logo.png',
|
||||||
|
link: 'https://www.nomadic-labs.com/',
|
||||||
|
pinned: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Tocqueville Group',
|
||||||
|
image: 'img/tq-logo.svg',
|
||||||
|
link: 'https://tqgroup.io/',
|
||||||
|
pinned: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Stove Labs',
|
||||||
|
image: 'img/stove-logo.png',
|
||||||
|
link: 'https://stove-labs.com',
|
||||||
|
pinned: true
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const Feature = (props) => (
|
||||||
|
<div className="feature" key={props.title}>
|
||||||
|
<img src={useBaseUrl(props.image)} />
|
||||||
|
<h1>{props.title}</h1>
|
||||||
|
<p>{props.content}</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const Partner = (props) => (
|
||||||
|
<a
|
||||||
|
href={props.link}
|
||||||
|
title={props.name}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
<img src={useBaseUrl(props.image)} />
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
|
||||||
|
function HomePage() {
|
||||||
|
return <Layout title="Homepage">
|
||||||
|
<div
|
||||||
|
id="homePage"
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'stretch',
|
||||||
|
alignItems: 'stretch',
|
||||||
|
fontSize: '20px',
|
||||||
|
flexDirection: 'column'
|
||||||
|
}}>
|
||||||
|
<div id="intro" className="centered">
|
||||||
|
<div id="callToAction">
|
||||||
|
<ul>
|
||||||
|
<li className="primary">
|
||||||
|
<a href="https://ide.ligolang.org">Try Online</a>
|
||||||
|
</li>
|
||||||
|
<li className="secondary">
|
||||||
|
<a href={useBaseUrl('/docs/intro/installation')}>Install</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div id="preview">
|
||||||
|
<h1>A friendly Smart Contract Language for Tezos</h1>
|
||||||
|
<p>Tezos was never so easy</p>
|
||||||
|
<CodeExamples />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="features" className="centered">
|
||||||
|
{FEATURES.map(entry =>
|
||||||
|
<Feature key={entry.title} title={entry.title} content={entry.content} image={entry.image} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div id="partners">
|
||||||
|
<div className="centered wrapper">
|
||||||
|
<span id="heading">Our Partners</span>
|
||||||
|
<div id="list">
|
||||||
|
{PARTNERS.filter(entry => entry.pinned).map(entry =>
|
||||||
|
<Partner key={entry.name} name={entry.name} image={entry.image} link={entry.link} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Layout>
|
||||||
|
}
|
||||||
|
|
||||||
|
export default HomePage;
|
||||||
|
|
||||||
|
|
113
gitlab-pages/website/src/pages/versions.js.fixme
Normal file
113
gitlab-pages/website/src/pages/versions.js.fixme
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
// /**
|
||||||
|
// * Copyright (c) 2017-present, Facebook, Inc.
|
||||||
|
// *
|
||||||
|
// * This source code is licensed under the MIT license found in the
|
||||||
|
// * LICENSE file in the root directory of this source tree.
|
||||||
|
// */
|
||||||
|
|
||||||
|
// const React = require('react');
|
||||||
|
|
||||||
|
// const CompLibrary = require('../../core/CompLibrary');
|
||||||
|
|
||||||
|
// const Container = CompLibrary.Container;
|
||||||
|
|
||||||
|
// const CWD = process.cwd();
|
||||||
|
|
||||||
|
// const versions = require(`${CWD}/versions.json`);
|
||||||
|
|
||||||
|
// function Versions(props) {
|
||||||
|
// const {config: siteConfig} = props;
|
||||||
|
// const latestVersion = versions[0];
|
||||||
|
// const repoUrl = `${siteConfig.repoUrl}`;
|
||||||
|
// return (
|
||||||
|
// <div className="docMainWrapper wrapper">
|
||||||
|
// <Container className="mainContainer versionsContainer">
|
||||||
|
// <div className="post">
|
||||||
|
// <header className="postHeader">
|
||||||
|
// <h1>{siteConfig.title} Versions </h1>
|
||||||
|
// </header>
|
||||||
|
// <h3 id="latest">Current version</h3>
|
||||||
|
// <table className="versions">
|
||||||
|
// <tbody>
|
||||||
|
// <tr>
|
||||||
|
// <th>{latestVersion}</th>
|
||||||
|
// <td>
|
||||||
|
// {/* You are supposed to change this href where appropriate
|
||||||
|
// Example: href="<baseUrl>/docs(/:language)/:id" */}
|
||||||
|
// <a
|
||||||
|
// href={`${siteConfig.baseUrl}${siteConfig.docsUrl}/${
|
||||||
|
// props.language ? props.language + '/' : ''
|
||||||
|
// }intro/installation`}>
|
||||||
|
// Documentation
|
||||||
|
// </a>
|
||||||
|
// </td>
|
||||||
|
// <td>
|
||||||
|
// <a href={repoUrl}>Source Code</a>
|
||||||
|
// </td>
|
||||||
|
// {/* <td>
|
||||||
|
// <a href="">Release Notes</a>
|
||||||
|
// </td> */}
|
||||||
|
// </tr>
|
||||||
|
// </tbody>
|
||||||
|
// </table>
|
||||||
|
// <h3 id="rc">Pre-release versions</h3>
|
||||||
|
// <table className="versions">
|
||||||
|
// <tbody>
|
||||||
|
// <tr>
|
||||||
|
// <th>next</th>
|
||||||
|
// <td>
|
||||||
|
// {/* You are supposed to change this href where appropriate
|
||||||
|
// Example: href="<baseUrl>/docs(/:language)/next/:id" */}
|
||||||
|
// <a
|
||||||
|
// href={`${siteConfig.baseUrl}${siteConfig.docsUrl}/${
|
||||||
|
// props.language ? props.language + '/' : ''
|
||||||
|
// }next/intro/installation`}>
|
||||||
|
// Documentation
|
||||||
|
// </a>
|
||||||
|
// </td>
|
||||||
|
// <td>
|
||||||
|
// <a href={repoUrl}>Source Code</a>
|
||||||
|
// </td>
|
||||||
|
// </tr>
|
||||||
|
// </tbody>
|
||||||
|
// </table>
|
||||||
|
// <h3 id="archive">Past Versions</h3>
|
||||||
|
// <p>Here you can find previous versions of the documentation.</p>
|
||||||
|
// <table className="versions">
|
||||||
|
// <tbody>
|
||||||
|
// {versions.map(
|
||||||
|
// version =>
|
||||||
|
// version !== latestVersion && version !== "next" && (
|
||||||
|
// <tr>
|
||||||
|
// <th>{version}</th>
|
||||||
|
// <td>
|
||||||
|
// {/* You are supposed to change this href where appropriate
|
||||||
|
// Example: href="<baseUrl>/docs(/:language)/:version/:id" */}
|
||||||
|
// <a
|
||||||
|
// href={`${siteConfig.baseUrl}${siteConfig.docsUrl}/${
|
||||||
|
// props.language ? props.language + '/' : ''
|
||||||
|
// }${version}/intro/installation`}>
|
||||||
|
// Documentation
|
||||||
|
// </a>
|
||||||
|
// </td>
|
||||||
|
// <td>
|
||||||
|
// <a href={`${repoUrl}/releases/tag/v${version}`}>
|
||||||
|
// Release Notes
|
||||||
|
// </a>
|
||||||
|
// </td>
|
||||||
|
// </tr>
|
||||||
|
// ),
|
||||||
|
// )}
|
||||||
|
// </tbody>
|
||||||
|
// </table>
|
||||||
|
// <p>
|
||||||
|
// You can find past versions of this project on{' '}
|
||||||
|
// <a href={repoUrl}>GitLab</a>.
|
||||||
|
// </p>
|
||||||
|
// </div>
|
||||||
|
// </Container>
|
||||||
|
// </div>
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// module.exports = Versions;
|
194
gitlab-pages/website/src/theme/CodeBlock/index.js
Normal file
194
gitlab-pages/website/src/theme/CodeBlock/index.js
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2017-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React, {useEffect, useState, useRef} from 'react';
|
||||||
|
import classnames from 'classnames';
|
||||||
|
import Highlight, {defaultProps} from 'prism-react-renderer';
|
||||||
|
const {Prism} = require("prism-react-renderer");
|
||||||
|
Prism.languages = {
|
||||||
|
...Prism.languages,
|
||||||
|
pascaligo: {
|
||||||
|
'comment': [
|
||||||
|
/\(\*[\s\S]+?\*\)/,
|
||||||
|
// /\{[\s\S]+?\}/,
|
||||||
|
/\/\/.*/
|
||||||
|
],
|
||||||
|
'string': {
|
||||||
|
pattern: /(?:'(?:''|[^'\r\n])*'|#[&$%]?[a-f\d]+)+|\^[a-z]/i,
|
||||||
|
greedy: true
|
||||||
|
},
|
||||||
|
'keyword': [
|
||||||
|
{
|
||||||
|
// Turbo Pascal
|
||||||
|
pattern: /(^|[^&])\b(?:absolute|array|asm|begin|case|const|constructor|destructor|do|downto|else|end|file|for|function|goto|if|implementation|inherited|inline|interface|label|nil|object|of|operator|packed|procedure|program|record|reintroduce|repeat|self|set|string|then|to|type|unit|until|uses|var|while|with)\b/i,
|
||||||
|
lookbehind: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Free Pascal
|
||||||
|
pattern: /(^|[^&])\b(?:dispose|exit|false|new|true)\b/i,
|
||||||
|
lookbehind: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Object Pascal
|
||||||
|
pattern: /(^|[^&])\b(?:class|dispinterface|except|exports|finalization|finally|initialization|inline|library|on|out|packed|property|raise|resourcestring|threadvar|try)\b/i,
|
||||||
|
lookbehind: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Modifiers
|
||||||
|
pattern: /(^|[^&])\b(?:absolute|abstract|alias|assembler|bitpacked|break|cdecl|continue|cppdecl|cvar|default|deprecated|dynamic|enumerator|experimental|export|external|far|far16|forward|generic|helper|implements|index|interrupt|iochecks|local|message|name|near|nodefault|noreturn|nostackframe|oldfpccall|otherwise|overload|override|pascal|platform|private|protected|public|published|read|register|reintroduce|result|safecall|saveregisters|softfloat|specialize|static|stdcall|stored|strict|unaligned|unimplemented|varargs|virtual|write)\b/i,
|
||||||
|
lookbehind: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'number': [
|
||||||
|
// Hexadecimal, octal and binary
|
||||||
|
/(?:[&%]\d+|\$[a-f\d]+)/i,
|
||||||
|
// Decimal
|
||||||
|
/\b\d+(?:\.\d+)?(?:e[+-]?\d+)?/i
|
||||||
|
],
|
||||||
|
'operator': [
|
||||||
|
/\.\.|\*\*|:=|<[<=>]?|>[>=]?|[+\-*\/]=?|[@^=]/i,
|
||||||
|
{
|
||||||
|
pattern: /(^|[^&])\b(?:and|as|div|exclude|in|include|is|mod|not|or|shl|shr|xor)\b/,
|
||||||
|
lookbehind: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'punctuation': /\(\.|\.\)|[()\[\]:;,.]/
|
||||||
|
},
|
||||||
|
reasonligo:
|
||||||
|
{...Prism.languages.reason,
|
||||||
|
'comment': [
|
||||||
|
/(^|[^\\])\/\*[\s\S]*?\*\//,
|
||||||
|
/\(\*[\s\S]*?\*\)/,
|
||||||
|
/\/\/.*/
|
||||||
|
]
|
||||||
|
|
||||||
|
},
|
||||||
|
cameligo: {...Prism.languages.ocaml,
|
||||||
|
'comment': [
|
||||||
|
/(^|[^\\])\/\*[\s\S]*?\*\//,
|
||||||
|
/\(\*[\s\S]*?\*\)/,
|
||||||
|
/\/\/.*/
|
||||||
|
]}
|
||||||
|
};
|
||||||
|
import defaultTheme from 'prism-react-renderer/themes/palenight';
|
||||||
|
import Clipboard from 'clipboard';
|
||||||
|
import rangeParser from 'parse-numeric-range';
|
||||||
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||||
|
import useThemeContext from '@theme/hooks/useThemeContext';
|
||||||
|
|
||||||
|
import styles from './styles.module.css';
|
||||||
|
|
||||||
|
const highlightLinesRangeRegex = /{([\d,-]+)}/;
|
||||||
|
|
||||||
|
export default ({children, className: languageClassName, metastring}) => {
|
||||||
|
const {
|
||||||
|
siteConfig: {
|
||||||
|
themeConfig: {prism = {}},
|
||||||
|
},
|
||||||
|
} = useDocusaurusContext();
|
||||||
|
|
||||||
|
const [showCopied, setShowCopied] = useState(false);
|
||||||
|
const [mounted, setMounted] = useState(false);
|
||||||
|
// The Prism theme on SSR is always the default theme but the site theme
|
||||||
|
// can be in a different mode. React hydration doesn't update DOM styles
|
||||||
|
// that come from SSR. Hence force a re-render after mounting to apply the
|
||||||
|
// current relevant styles. There will be a flash seen of the original
|
||||||
|
// styles seen using this current approach but that's probably ok. Fixing
|
||||||
|
// the flash will require changing the theming approach and is not worth it
|
||||||
|
// at this point.
|
||||||
|
useEffect(() => {
|
||||||
|
setMounted(true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const target = useRef(null);
|
||||||
|
const button = useRef(null);
|
||||||
|
let highlightLines = [];
|
||||||
|
|
||||||
|
const {isDarkTheme} = useThemeContext();
|
||||||
|
const lightModeTheme = prism.theme || defaultTheme;
|
||||||
|
const darkModeTheme = prism.darkTheme || lightModeTheme;
|
||||||
|
const prismTheme = isDarkTheme ? darkModeTheme : lightModeTheme;
|
||||||
|
|
||||||
|
if (metastring && highlightLinesRangeRegex.test(metastring)) {
|
||||||
|
const highlightLinesRange = metastring.match(highlightLinesRangeRegex)[1];
|
||||||
|
highlightLines = rangeParser.parse(highlightLinesRange).filter(n => n > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let clipboard;
|
||||||
|
|
||||||
|
if (button.current) {
|
||||||
|
clipboard = new Clipboard(button.current, {
|
||||||
|
target: () => target.current,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (clipboard) {
|
||||||
|
clipboard.destroy();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [button.current, target.current]);
|
||||||
|
|
||||||
|
let language =
|
||||||
|
languageClassName && languageClassName.replace(/language-/, '');
|
||||||
|
|
||||||
|
if (!language && prism.defaultLanguage) {
|
||||||
|
language = prism.defaultLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCopyCode = () => {
|
||||||
|
window.getSelection().empty();
|
||||||
|
setShowCopied(true);
|
||||||
|
|
||||||
|
setTimeout(() => setShowCopied(false), 2000);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Highlight
|
||||||
|
{...defaultProps}
|
||||||
|
key={mounted}
|
||||||
|
theme={prismTheme}
|
||||||
|
code={children.trim()}
|
||||||
|
language={language}>
|
||||||
|
{({className, style, tokens, getLineProps, getTokenProps}) => (
|
||||||
|
<pre className={classnames(className, styles.codeBlock)}>
|
||||||
|
<button
|
||||||
|
ref={button}
|
||||||
|
type="button"
|
||||||
|
aria-label="Copy code to clipboard"
|
||||||
|
className={styles.copyButton}
|
||||||
|
onClick={handleCopyCode}>
|
||||||
|
{showCopied ? 'Copied' : 'Copy'}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<code ref={target} className={styles.codeBlockLines} style={style}>
|
||||||
|
{tokens.map((line, i) => {
|
||||||
|
if (line.length === 1 && line[0].content === '') {
|
||||||
|
line[0].content = '\n'; // eslint-disable-line no-param-reassign
|
||||||
|
}
|
||||||
|
|
||||||
|
const lineProps = getLineProps({line, key: i});
|
||||||
|
|
||||||
|
if (highlightLines.includes(i + 1)) {
|
||||||
|
lineProps.className = `${lineProps.className} docusaurus-highlight-code-line`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div key={i} {...lineProps}>
|
||||||
|
{line.map((token, key) => (
|
||||||
|
<span key={key} {...getTokenProps({token, key})} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</code>
|
||||||
|
</pre>
|
||||||
|
)}
|
||||||
|
</Highlight>
|
||||||
|
);
|
||||||
|
};
|
45
gitlab-pages/website/src/theme/CodeBlock/styles.module.css
Normal file
45
gitlab-pages/website/src/theme/CodeBlock/styles.module.css
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2017-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.codeBlock {
|
||||||
|
overflow: auto;
|
||||||
|
display: block;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copyButton {
|
||||||
|
background: rgb(1, 22, 39);
|
||||||
|
border: 1px solid rgb(214, 222, 235);
|
||||||
|
border-radius: var(--ifm-global-radius);
|
||||||
|
color: rgb(214, 222, 235);
|
||||||
|
cursor: pointer;
|
||||||
|
line-height: 12px;
|
||||||
|
opacity: 0;
|
||||||
|
outline: none;
|
||||||
|
padding: 4px 8px;
|
||||||
|
position: absolute;
|
||||||
|
right: var(--ifm-pre-padding);
|
||||||
|
top: var(--ifm-pre-padding);
|
||||||
|
visibility: hidden;
|
||||||
|
transition: opacity 200ms ease-in-out, visibility 200ms ease-in-out,
|
||||||
|
bottom 200ms ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.codeBlock:hover > .copyButton {
|
||||||
|
visibility: visible;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.codeBlockLines {
|
||||||
|
background-color: transparent;
|
||||||
|
border-radius: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
float: left;
|
||||||
|
min-width: 100%;
|
||||||
|
padding: var(--ifm-pre-padding);
|
||||||
|
}
|
77
gitlab-pages/website/src/theme/DocPage/index.js
Normal file
77
gitlab-pages/website/src/theme/DocPage/index.js
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2017-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import {MDXProvider} from '@mdx-js/react';
|
||||||
|
|
||||||
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||||
|
import renderRoutes from '@docusaurus/renderRoutes';
|
||||||
|
import Layout from '@theme/Layout';
|
||||||
|
import DocSidebar from '@theme/DocSidebar';
|
||||||
|
import MDXComponents from '@theme/MDXComponents';
|
||||||
|
import NotFound from '@theme/NotFound';
|
||||||
|
import {matchPath} from '@docusaurus/router';
|
||||||
|
|
||||||
|
import styles from './styles.module.css';
|
||||||
|
|
||||||
|
import SyntaxContext from '@theme/Syntax/SyntaxContext';
|
||||||
|
|
||||||
|
function DocPage(props) {
|
||||||
|
const {route: baseRoute, docsMetadata, location} = props;
|
||||||
|
|
||||||
|
// case-sensitive route such as it is defined in the sidebar
|
||||||
|
const currentRoute =
|
||||||
|
baseRoute.routes.find(route => {
|
||||||
|
return matchPath(location.pathname, route);
|
||||||
|
}) || {};
|
||||||
|
const {permalinkToSidebar, docsSidebars, version} = docsMetadata;
|
||||||
|
const sidebar = permalinkToSidebar[currentRoute.path];
|
||||||
|
const {
|
||||||
|
siteConfig: {themeConfig = {}} = {},
|
||||||
|
isClient,
|
||||||
|
} = useDocusaurusContext();
|
||||||
|
const {sidebarCollapsible = true} = themeConfig;
|
||||||
|
|
||||||
|
let defaultSyntax = 'pascaligo';
|
||||||
|
if (isClient) {
|
||||||
|
defaultSyntax = localStorage.getItem('syntax') || defaultSyntax
|
||||||
|
}
|
||||||
|
|
||||||
|
const [syntax, setSyntax] = useState(defaultSyntax);
|
||||||
|
|
||||||
|
if (Object.keys(currentRoute).length === 0) {
|
||||||
|
return <NotFound {...props} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Layout version={version} key={isClient}>
|
||||||
|
<SyntaxContext.Provider value={syntax}>
|
||||||
|
<div className={styles.docPage}>
|
||||||
|
{sidebar && (
|
||||||
|
<div className={styles.docSidebarContainer}>
|
||||||
|
<DocSidebar
|
||||||
|
docsSidebars={docsSidebars}
|
||||||
|
path={currentRoute.path}
|
||||||
|
sidebar={sidebar}
|
||||||
|
sidebarCollapsible={sidebarCollapsible}
|
||||||
|
syntax={syntax}
|
||||||
|
onSyntaxChange={l => setSyntax(l)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<main className={styles.docMainContainer}>
|
||||||
|
<MDXProvider components={MDXComponents}>
|
||||||
|
{renderRoutes(baseRoute.routes)}
|
||||||
|
</MDXProvider>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</SyntaxContext.Provider>
|
||||||
|
</Layout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DocPage;
|
28
gitlab-pages/website/src/theme/DocPage/styles.module.css
Normal file
28
gitlab-pages/website/src/theme/DocPage/styles.module.css
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2017-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.docPage {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.docSidebarContainer {
|
||||||
|
border-right: 1px solid var(--ifm-contents-border-color);
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 300px;
|
||||||
|
position: relative;
|
||||||
|
top: calc(-1 * var(--ifm-navbar-height));
|
||||||
|
}
|
||||||
|
|
||||||
|
.docMainContainer {
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 996px) {
|
||||||
|
.docPage {
|
||||||
|
display: inherit;
|
||||||
|
}
|
||||||
|
}
|
229
gitlab-pages/website/src/theme/DocSidebar/index.js
Normal file
229
gitlab-pages/website/src/theme/DocSidebar/index.js
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2017-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React, {useState, useCallback} from 'react';
|
||||||
|
import classnames from 'classnames';
|
||||||
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||||
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||||
|
import useLockBodyScroll from '@theme/hooks/useLockBodyScroll';
|
||||||
|
import Link from '@docusaurus/Link';
|
||||||
|
import isInternalUrl from '@docusaurus/utils'; // eslint-disable-line import/no-extraneous-dependencies
|
||||||
|
|
||||||
|
import styles from './styles.module.css';
|
||||||
|
|
||||||
|
import SyntaxSwitch from '../Syntax/SyntaxSwitch';
|
||||||
|
|
||||||
|
|
||||||
|
const MOBILE_TOGGLE_SIZE = 24;
|
||||||
|
|
||||||
|
function DocSidebarItem({item, onItemClick, collapsible}) {
|
||||||
|
const {items, href, label, type} = item;
|
||||||
|
const [collapsed, setCollapsed] = useState(item.collapsed);
|
||||||
|
const [prevCollapsedProp, setPreviousCollapsedProp] = useState(null);
|
||||||
|
|
||||||
|
// If the collapsing state from props changed, probably a navigation event
|
||||||
|
// occurred. Overwrite the component's collapsed state with the props'
|
||||||
|
// collapsed value.
|
||||||
|
if (item.collapsed !== prevCollapsedProp) {
|
||||||
|
setPreviousCollapsedProp(item.collapsed);
|
||||||
|
setCollapsed(item.collapsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleItemClick = useCallback(e => {
|
||||||
|
e.preventDefault();
|
||||||
|
setCollapsed(state => !state);
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case 'category':
|
||||||
|
return (
|
||||||
|
items.length > 0 && (
|
||||||
|
<li
|
||||||
|
className={classnames('menu__list-item', {
|
||||||
|
'menu__list-item--collapsed': collapsed,
|
||||||
|
})}
|
||||||
|
key={label}>
|
||||||
|
<a
|
||||||
|
className={classnames('menu__link', {
|
||||||
|
'menu__link--sublist': collapsible,
|
||||||
|
'menu__link--active': collapsible && !item.collapsed,
|
||||||
|
})}
|
||||||
|
href="#!"
|
||||||
|
onClick={collapsible ? handleItemClick : undefined}>
|
||||||
|
{label}
|
||||||
|
</a>
|
||||||
|
<ul className="menu__list">
|
||||||
|
{items.map(childItem => (
|
||||||
|
<DocSidebarItem
|
||||||
|
key={childItem.label}
|
||||||
|
item={childItem}
|
||||||
|
onItemClick={onItemClick}
|
||||||
|
collapsible={collapsible}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
case 'link':
|
||||||
|
default:
|
||||||
|
return (
|
||||||
|
<li className="menu__list-item" key={label}>
|
||||||
|
<Link
|
||||||
|
className="menu__link"
|
||||||
|
to={href}
|
||||||
|
{...(isInternalUrl(href)
|
||||||
|
? {
|
||||||
|
activeClassName: 'menu__link--active',
|
||||||
|
exact: true,
|
||||||
|
onClick: onItemClick,
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
target: '_blank',
|
||||||
|
rel: 'noreferrer noopener',
|
||||||
|
})}>
|
||||||
|
{label}
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate the category collapsing state when a page navigation occurs.
|
||||||
|
// We want to automatically expand the categories which contains the current page.
|
||||||
|
function mutateSidebarCollapsingState(item, path) {
|
||||||
|
const {items, href, type} = item;
|
||||||
|
switch (type) {
|
||||||
|
case 'category': {
|
||||||
|
const anyChildItemsActive =
|
||||||
|
items
|
||||||
|
.map(childItem => mutateSidebarCollapsingState(childItem, path))
|
||||||
|
.filter(val => val).length > 0;
|
||||||
|
// eslint-disable-next-line no-param-reassign
|
||||||
|
item.collapsed = !anyChildItemsActive;
|
||||||
|
return anyChildItemsActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'link':
|
||||||
|
default:
|
||||||
|
return href === path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function DocSidebar(props) {
|
||||||
|
const [showResponsiveSidebar, setShowResponsiveSidebar] = useState(false);
|
||||||
|
const {
|
||||||
|
siteConfig: {themeConfig: {navbar: {title, logo = {}} = {}}} = {}, isClient
|
||||||
|
} = useDocusaurusContext();
|
||||||
|
const logoUrl = useBaseUrl(logo.src);
|
||||||
|
|
||||||
|
const {
|
||||||
|
docsSidebars,
|
||||||
|
path,
|
||||||
|
sidebar: currentSidebar,
|
||||||
|
sidebarCollapsible,
|
||||||
|
} = props;
|
||||||
|
|
||||||
|
useLockBodyScroll(showResponsiveSidebar);
|
||||||
|
|
||||||
|
if (!currentSidebar) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const sidebarData = docsSidebars[currentSidebar];
|
||||||
|
|
||||||
|
if (!sidebarData) {
|
||||||
|
throw new Error(
|
||||||
|
`Cannot find the sidebar "${currentSidebar}" in the sidebar config!`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sidebarCollapsible) {
|
||||||
|
sidebarData.forEach(sidebarItem =>
|
||||||
|
mutateSidebarCollapsingState(sidebarItem, path),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.sidebar}>
|
||||||
|
<div className={styles.sidebarLogo}>
|
||||||
|
{logo != null && <img src={logoUrl} alt={logo.alt} />}
|
||||||
|
{title != null && <strong>{title}</strong>}
|
||||||
|
</div>
|
||||||
|
{isClient && document.location.pathname.startsWith('/docs') && !showResponsiveSidebar ?
|
||||||
|
<div className={styles.switchContainer}>
|
||||||
|
Display syntax: <SyntaxSwitch syntax={props.syntax} onSyntaxChange={s => props.onSyntaxChange(s)} />
|
||||||
|
</div>
|
||||||
|
:
|
||||||
|
null
|
||||||
|
}
|
||||||
|
<div
|
||||||
|
className={classnames('menu', 'menu--responsive', styles.menu, {
|
||||||
|
'menu--show': showResponsiveSidebar,
|
||||||
|
})}>
|
||||||
|
{isClient && document.location.pathname.startsWith('/docs') && showResponsiveSidebar ?
|
||||||
|
<div className={styles.switchContainerResponsive}>
|
||||||
|
Display syntax:
|
||||||
|
<SyntaxSwitch syntax={props.syntax} onSyntaxChange={s => props.onSyntaxChange(s)} />
|
||||||
|
</div>
|
||||||
|
:
|
||||||
|
null
|
||||||
|
}
|
||||||
|
<button
|
||||||
|
aria-label={showResponsiveSidebar ? 'Close Menu' : 'Open Menu'}
|
||||||
|
className="button button--secondary button--sm menu__button"
|
||||||
|
type="button"
|
||||||
|
onClick={() => {
|
||||||
|
setShowResponsiveSidebar(!showResponsiveSidebar);
|
||||||
|
}}>
|
||||||
|
{showResponsiveSidebar ? (
|
||||||
|
<span
|
||||||
|
className={classnames(
|
||||||
|
styles.sidebarMenuIcon,
|
||||||
|
styles.sidebarMenuCloseIcon,
|
||||||
|
)}>
|
||||||
|
×
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<svg
|
||||||
|
className={styles.sidebarMenuIcon}
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
height={MOBILE_TOGGLE_SIZE}
|
||||||
|
width={MOBILE_TOGGLE_SIZE}
|
||||||
|
viewBox="0 0 32 32"
|
||||||
|
role="img"
|
||||||
|
focusable="false">
|
||||||
|
<title>Menu</title>
|
||||||
|
<path
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeMiterlimit="10"
|
||||||
|
strokeWidth="2"
|
||||||
|
d="M4 7h22M4 15h22M4 23h22"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
<ul className="menu__list">
|
||||||
|
{sidebarData.map(item => (
|
||||||
|
<DocSidebarItem
|
||||||
|
key={item.label}
|
||||||
|
item={item}
|
||||||
|
onItemClick={() => {
|
||||||
|
setShowResponsiveSidebar(false);
|
||||||
|
}}
|
||||||
|
collapsible={sidebarCollapsible}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DocSidebar;
|
90
gitlab-pages/website/src/theme/DocSidebar/styles.module.css
Normal file
90
gitlab-pages/website/src/theme/DocSidebar/styles.module.css
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2017-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@media (min-width: 997px) {
|
||||||
|
.sidebar {
|
||||||
|
height: 100vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
padding-top: var(--ifm-navbar-height);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar::-webkit-scrollbar {
|
||||||
|
width: 7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar::-webkit-scrollbar-track {
|
||||||
|
background: #f1f1f1;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar::-webkit-scrollbar-thumb {
|
||||||
|
background: #888;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebarLogo {
|
||||||
|
display: flex !important;
|
||||||
|
align-items: center;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
margin: 0 var(--ifm-navbar-padding-horizontal);
|
||||||
|
height: var(--ifm-navbar-height);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebarLogo img {
|
||||||
|
margin-right: 0.5rem;
|
||||||
|
height: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu {
|
||||||
|
padding: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switchContainer {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
background-color: var(--ifm-pre-background);
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 1rem 0;
|
||||||
|
border-bottom: 1px solid var(--ifm-contents-border-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.switchContainerResponsive {
|
||||||
|
background-color: var(--ifm-pre-background);
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebarLogo {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebarMenuIcon {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebarMenuCloseIcon {
|
||||||
|
display: inline-flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 24px;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
font-weight: var(--ifm-font-weight-bold);
|
||||||
|
line-height: 0.9;
|
||||||
|
width: 24px;
|
||||||
|
}
|
201
gitlab-pages/website/src/theme/Navbar/index.js
Normal file
201
gitlab-pages/website/src/theme/Navbar/index.js
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2017-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React, {useCallback, useState} from 'react';
|
||||||
|
import Link from '@docusaurus/Link';
|
||||||
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||||
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||||
|
|
||||||
|
import SearchBar from '@theme/SearchBar';
|
||||||
|
import Toggle from '@theme/Toggle';
|
||||||
|
|
||||||
|
import classnames from 'classnames';
|
||||||
|
|
||||||
|
import useThemeContext from '@theme/hooks/useThemeContext';
|
||||||
|
import useHideableNavbar from '@theme/hooks/useHideableNavbar';
|
||||||
|
import useLockBodyScroll from '@theme/hooks/useLockBodyScroll';
|
||||||
|
|
||||||
|
import styles from './styles.module.css';
|
||||||
|
|
||||||
|
function NavLink({to, href, label, position, ...props}) {
|
||||||
|
const toUrl = useBaseUrl(to);
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
className="navbar__item navbar__link"
|
||||||
|
{...(href
|
||||||
|
? {
|
||||||
|
target: '_blank',
|
||||||
|
rel: 'noopener noreferrer',
|
||||||
|
href,
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
activeClassName: 'navbar__link--active',
|
||||||
|
to: toUrl,
|
||||||
|
})}
|
||||||
|
{...props}>
|
||||||
|
{label}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Navbar(props) {
|
||||||
|
const context = useDocusaurusContext();
|
||||||
|
const {siteConfig = {}} = context;
|
||||||
|
const {baseUrl, themeConfig = {}} = siteConfig;
|
||||||
|
const {navbar = {}, disableDarkMode = false} = themeConfig;
|
||||||
|
const {title, logo = {}, links = [], hideOnScroll = false} = navbar;
|
||||||
|
|
||||||
|
const [sidebarShown, setSidebarShown] = useState(false);
|
||||||
|
const [isSearchBarExpanded, setIsSearchBarExpanded] = useState(false);
|
||||||
|
|
||||||
|
const {isDarkTheme, setLightTheme, setDarkTheme} = useThemeContext();
|
||||||
|
const {navbarRef, isNavbarVisible} = useHideableNavbar(hideOnScroll);
|
||||||
|
|
||||||
|
useLockBodyScroll(sidebarShown);
|
||||||
|
|
||||||
|
const showSidebar = useCallback(() => {
|
||||||
|
setSidebarShown(true);
|
||||||
|
}, [setSidebarShown]);
|
||||||
|
const hideSidebar = useCallback(() => {
|
||||||
|
setSidebarShown(false);
|
||||||
|
}, [setSidebarShown]);
|
||||||
|
|
||||||
|
const onToggleChange = useCallback(
|
||||||
|
e => (e.target.checked ? setDarkTheme() : setLightTheme()),
|
||||||
|
[setLightTheme, setDarkTheme],
|
||||||
|
);
|
||||||
|
|
||||||
|
const logoLink = logo.href || baseUrl;
|
||||||
|
const isExternalLogoLink = /http/.test(logoLink);
|
||||||
|
const logoLinkProps = isExternalLogoLink
|
||||||
|
? {
|
||||||
|
rel: 'noopener noreferrer',
|
||||||
|
target: '_blank',
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
const logoSrc = logo.srcDark && isDarkTheme ? logo.srcDark : logo.src;
|
||||||
|
const logoImageUrl = useBaseUrl(logoSrc);
|
||||||
|
return (
|
||||||
|
<nav
|
||||||
|
ref={navbarRef}
|
||||||
|
className={classnames('navbar', 'navbar--light', 'navbar--fixed-top', {
|
||||||
|
'navbar-sidebar--show': sidebarShown,
|
||||||
|
[styles.navbarHideable]: hideOnScroll,
|
||||||
|
[styles.navbarHidden]: !isNavbarVisible,
|
||||||
|
})}>
|
||||||
|
<div className="navbar__inner">
|
||||||
|
<div className="navbar__items">
|
||||||
|
<div
|
||||||
|
aria-label="Navigation bar toggle"
|
||||||
|
className="navbar__toggle"
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
|
onClick={showSidebar}
|
||||||
|
onKeyDown={showSidebar}>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="30"
|
||||||
|
height="30"
|
||||||
|
viewBox="0 0 30 30"
|
||||||
|
role="img"
|
||||||
|
focusable="false">
|
||||||
|
<title>Menu</title>
|
||||||
|
<path
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeMiterlimit="10"
|
||||||
|
strokeWidth="2"
|
||||||
|
d="M4 7h22M4 15h22M4 23h22"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<Link className="navbar__brand" to={logoLink} {...logoLinkProps}>
|
||||||
|
{logo != null && (
|
||||||
|
<img className="navbar__logo" src={logoImageUrl} alt={logo.alt} />
|
||||||
|
)}
|
||||||
|
{title != null && (
|
||||||
|
<strong
|
||||||
|
className={isSearchBarExpanded ? styles.hideLogoText : ''}>
|
||||||
|
{title}
|
||||||
|
</strong>
|
||||||
|
)}
|
||||||
|
</Link>
|
||||||
|
{links
|
||||||
|
.filter(linkItem => linkItem.position !== 'right')
|
||||||
|
.map((linkItem, i) => (
|
||||||
|
<NavLink {...linkItem} key={i} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div className="navbar__items navbar__items--right">
|
||||||
|
{links
|
||||||
|
.filter(linkItem => linkItem.position === 'right')
|
||||||
|
.map((linkItem, i) => (
|
||||||
|
<NavLink {...linkItem} key={i} />
|
||||||
|
))}
|
||||||
|
{!disableDarkMode && (
|
||||||
|
<Toggle
|
||||||
|
className={styles.displayOnlyInLargeViewport}
|
||||||
|
aria-label="Dark mode toggle"
|
||||||
|
checked={isDarkTheme}
|
||||||
|
onChange={onToggleChange}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<SearchBar
|
||||||
|
handleSearchBarToggle={setIsSearchBarExpanded}
|
||||||
|
isSearchBarExpanded={isSearchBarExpanded}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
role="presentation"
|
||||||
|
className="navbar-sidebar__backdrop"
|
||||||
|
onClick={hideSidebar}
|
||||||
|
/>
|
||||||
|
<div className="navbar-sidebar">
|
||||||
|
<div className="navbar-sidebar__brand">
|
||||||
|
<Link
|
||||||
|
className="navbar__brand"
|
||||||
|
onClick={hideSidebar}
|
||||||
|
to={logoLink}
|
||||||
|
{...logoLinkProps}>
|
||||||
|
{logo != null && (
|
||||||
|
<img className="navbar__logo" src={logoImageUrl} alt={logo.alt} />
|
||||||
|
)}
|
||||||
|
{title != null && <strong>{title}</strong>}
|
||||||
|
</Link>
|
||||||
|
{!disableDarkMode && sidebarShown && (
|
||||||
|
<Toggle
|
||||||
|
aria-label="Dark mode toggle in sidebar"
|
||||||
|
checked={isDarkTheme}
|
||||||
|
onChange={onToggleChange}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="navbar-sidebar__items">
|
||||||
|
<div className="menu">
|
||||||
|
<ul className="menu__list">
|
||||||
|
{links.map((linkItem, i) => (
|
||||||
|
<li className="menu__list-item" key={i}>
|
||||||
|
<NavLink
|
||||||
|
className="menu__link"
|
||||||
|
{...linkItem}
|
||||||
|
onClick={hideSidebar}
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Navbar;
|
26
gitlab-pages/website/src/theme/Navbar/styles.module.css
Normal file
26
gitlab-pages/website/src/theme/Navbar/styles.module.css
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2017-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@media screen and (max-width: 997px) {
|
||||||
|
.displayOnlyInLargeViewport {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 360px) {
|
||||||
|
.hideLogoText {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbarHideable {
|
||||||
|
transition: top 0.2s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbarHidden {
|
||||||
|
top: calc(var(--ifm-navbar-height) * -1) !important;
|
||||||
|
}
|
6
gitlab-pages/website/src/theme/Syntax/SyntaxContext.js
Normal file
6
gitlab-pages/website/src/theme/Syntax/SyntaxContext.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
const SyntaxContext = React.createContext('pascaligo');
|
||||||
|
|
||||||
|
export default SyntaxContext;
|
||||||
|
|
15
gitlab-pages/website/src/theme/Syntax/SyntaxSwitch.js
Normal file
15
gitlab-pages/website/src/theme/Syntax/SyntaxSwitch.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import styles from './styles.module.css';
|
||||||
|
|
||||||
|
function SyntaxSwitch (props) {
|
||||||
|
return (
|
||||||
|
<select className={styles.syntaxSwitch} defaultValue={props.syntax} onChange={e => props.onSyntaxChange(e.target.value)}>
|
||||||
|
<option value="pascaligo">PascaLIGO</option>
|
||||||
|
<option value="cameligo">CameLIGO</option>
|
||||||
|
<option value="reasonligo">ReasonLIGO</option>
|
||||||
|
</select>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SyntaxSwitch
|
18
gitlab-pages/website/src/theme/Syntax/index.js
Normal file
18
gitlab-pages/website/src/theme/Syntax/index.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import SyntaxContext from './SyntaxContext'
|
||||||
|
|
||||||
|
function Syntax(props) {
|
||||||
|
return (
|
||||||
|
<SyntaxContext.Consumer>
|
||||||
|
{(syntax => {
|
||||||
|
if (syntax === props.syntax) {
|
||||||
|
return props.children
|
||||||
|
} else {
|
||||||
|
return <></>
|
||||||
|
}
|
||||||
|
})}
|
||||||
|
</SyntaxContext.Consumer>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Syntax
|
37
gitlab-pages/website/src/theme/Syntax/styles.module.css
Normal file
37
gitlab-pages/website/src/theme/Syntax/styles.module.css
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
.syntaxSwitch {
|
||||||
|
display: block;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: bold;
|
||||||
|
line-height: 1rem;
|
||||||
|
padding: .6em 1.4em .5em .8em;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: none;
|
||||||
|
color: var(--color-primary-text);
|
||||||
|
-moz-appearance: none;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
background-color: transparent;
|
||||||
|
background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
|
||||||
|
background-repeat: no-repeat, repeat;
|
||||||
|
background-position: right .7em top 50%, 0 0;
|
||||||
|
background-size: .65em auto, 100%;
|
||||||
|
}
|
||||||
|
.syntaxSwitch::-ms-expand {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.syntaxSwitch:hover {
|
||||||
|
border-color: #888;
|
||||||
|
}
|
||||||
|
.syntaxSwitch:focus {
|
||||||
|
border-color: #aaa;
|
||||||
|
box-shadow: 0 0 1px 3px rgba(59, 153, 252, .7);
|
||||||
|
box-shadow: 0 0 0 3px -moz-mac-focusring;
|
||||||
|
color: var(--color-primary-text);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
.syntaxSwitch option {
|
||||||
|
color: var(--color-primary-text);
|
||||||
|
font-weight:normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,5 +1,28 @@
|
|||||||
|
@import url('/fonts/inter.css');
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--ifm-color-primary: #0e74ff;
|
||||||
|
--ifm-color-primary-dark: rgb(33, 175, 144);
|
||||||
|
--ifm-color-primary-darker: rgb(31, 165, 136);
|
||||||
|
--ifm-color-primary-darkest: rgb(26, 136, 112);
|
||||||
|
--ifm-color-primary-light: rgb(70, 203, 174);
|
||||||
|
--ifm-color-primary-lighter: rgb(102, 212, 189);
|
||||||
|
--ifm-color-primary-lightest: #92e0d0;
|
||||||
|
--blockquote-color: #efefef;
|
||||||
|
--ifm-code-font-size: .9rem;
|
||||||
|
|
||||||
|
|
||||||
|
/* header */
|
||||||
|
--ifm-navbar-link-hover-color: #0e74ff;
|
||||||
|
|
||||||
|
/* footer */
|
||||||
|
--ifm-footer-title-color: #fff;
|
||||||
|
--ifm-footer-background-color: #0d0f33;
|
||||||
|
--ifm-footer-link-hover-color: hsla(0,0%,100%,.6);
|
||||||
|
--ifm-footer-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--primary-brand-color: #0e74ff;
|
|
||||||
--secondary-brand-color: #fc683a;
|
--secondary-brand-color: #fc683a;
|
||||||
--blue: #3aa0ff;
|
--blue: #3aa0ff;
|
||||||
--lighter-blue: #e1f1ff;
|
--lighter-blue: #e1f1ff;
|
||||||
@ -24,12 +47,19 @@
|
|||||||
--padding-level-6: 100px;
|
--padding-level-6: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html[data-theme='dark'] {
|
||||||
|
--color-primary-text: white;
|
||||||
|
--blockquote-color: var(--ifm-navbar-background-color);
|
||||||
|
}
|
||||||
|
|
||||||
html {
|
html {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: 'Open Sans', sans-serif;
|
font-family: 'Open Sans', sans-serif;
|
||||||
|
font-family: 'Inter var',SF Pro Text,Roboto,-apple-system,BlinkMacSystemFont,Helvetica Neue,Arial,sans-serif;
|
||||||
|
font-weight: 400;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
color: var(--color-primary-text);
|
color: var(--color-primary-text);
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
@ -39,8 +69,8 @@ body {
|
|||||||
* Docusaurus overrides
|
* Docusaurus overrides
|
||||||
*/
|
*/
|
||||||
code {
|
code {
|
||||||
font-family: 'Source Code Pro', monospace;
|
/* font-family: 'Source Code Pro', monospace; */
|
||||||
background: var(--light-blue);
|
font-family: Menlo,Roboto Mono,SFMono-Regular,Segoe UI,Courier,monospace;
|
||||||
margin-left: 2px;
|
margin-left: 2px;
|
||||||
margin-right: 2px;
|
margin-right: 2px;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
@ -66,7 +96,6 @@ h1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
font-size: 2.25rem;
|
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
margin-top: 1.5rem;
|
margin-top: 1.5rem;
|
||||||
}
|
}
|
||||||
@ -182,7 +211,7 @@ p {
|
|||||||
.navigationSlider .slidingNav ul li.siteNavItemActive > a,
|
.navigationSlider .slidingNav ul li.siteNavItemActive > a,
|
||||||
.navigationSlider .slidingNav ul li.siteNavGroupActive > a {
|
.navigationSlider .slidingNav ul li.siteNavGroupActive > a {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
color: var(--primary-brand-color) !important;
|
color: var(--ifm-color-primary) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navSearchWrapper:before {
|
.navSearchWrapper:before {
|
||||||
@ -249,20 +278,19 @@ p {
|
|||||||
}
|
}
|
||||||
|
|
||||||
blockquote {
|
blockquote {
|
||||||
background-color: #efefef;
|
background-color: var(--blockquote-color);
|
||||||
border-left: 5px solid var(--color-primary-text);
|
border-left: 5px solid var(--color-primary-text);
|
||||||
color: var(--color-primary-text);
|
color: var(--color-primary-text);
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
blockquote code {
|
blockquote code {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
background: var(--light-blue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a,
|
a,
|
||||||
a:hover {
|
a:hover {
|
||||||
color: var(--primary-brand-color);
|
color: var(--ifm-color-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.docMainWrapper a:hover {
|
.docMainWrapper a:hover {
|
||||||
@ -333,7 +361,7 @@ a:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.navListItemActive a {
|
.navListItemActive a {
|
||||||
color: var(--primary-brand-color) !important;
|
color: var(--ifm-color-primary) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.onPageNav > .toc-headings {
|
.onPageNav > .toc-headings {
|
||||||
@ -366,7 +394,7 @@ a:hover {
|
|||||||
.button:hover {
|
.button:hover {
|
||||||
border-radius: 36px;
|
border-radius: 36px;
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
background-color: var(--primary-brand-color);
|
background-color: var(--ifm-color-primary);
|
||||||
min-width: 130px;
|
min-width: 130px;
|
||||||
color: var(--color-white);
|
color: var(--color-white);
|
||||||
}
|
}
|
||||||
@ -469,7 +497,7 @@ a:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.primary {
|
.primary {
|
||||||
color: var(--primary-brand-color);
|
color: var(--ifm-color-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.secondary {
|
.secondary {
|
||||||
@ -509,10 +537,13 @@ a:hover {
|
|||||||
#homePage #intro {
|
#homePage #intro {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#callToAction {
|
||||||
|
margin-top: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
#homePage #intro #callToAction ul {
|
#homePage #intro #callToAction ul {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@ -536,8 +567,8 @@ a:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#homePage #intro #callToAction ul li.primary:hover {
|
#homePage #intro #callToAction ul li.primary:hover {
|
||||||
background-color: var(--primary-brand-color);
|
background-color: var(--ifm-color-primary);
|
||||||
border-left: 4px solid var(--primary-brand-color);
|
border-left: 4px solid var(--ifm-color-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
#homePage #intro #callToAction ul li.secondary:hover {
|
#homePage #intro #callToAction ul li.secondary:hover {
|
||||||
@ -547,11 +578,13 @@ a:hover {
|
|||||||
|
|
||||||
#homePage #intro #callToAction ul li a {
|
#homePage #intro #callToAction ul li a {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#homePage #intro #preview .hljs {
|
#homePage #intro #preview {
|
||||||
min-width: 700px;
|
min-width: 700px;
|
||||||
min-height: 450px;
|
min-height: 450px;
|
||||||
|
max-width: 400px
|
||||||
}
|
}
|
||||||
|
|
||||||
#homePage #intro #preview p {
|
#homePage #intro #preview p {
|
||||||
@ -559,13 +592,14 @@ a:hover {
|
|||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#homePage #features {
|
#features {
|
||||||
margin: 100px auto;
|
margin: 100px auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#homePage #features .feature {
|
#features .feature {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -573,46 +607,47 @@ a:hover {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#homePage #features .feature p {
|
#features .feature p {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 1.25em;
|
font-size: 1.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
#homePage #partners {
|
#partners {
|
||||||
background-color: var(--primary-brand-color);
|
background-color: var(--ifm-color-primary);
|
||||||
color: white;
|
color: white;
|
||||||
font-size: 2.8125em;
|
font-size: 2.8rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding: 50px 0;
|
padding: 50px 0;
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#homePage #partners .wrapper {
|
#partners .wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#homePage #partners #heading {
|
#partners #heading {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
width: 200px;
|
width: 200px;
|
||||||
line-height: 1em;
|
line-height: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#homePage #partners #list {
|
#partners #list {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
#homePage #partners a {
|
#partners a {
|
||||||
line-height: 0;
|
line-height: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#homePage #partners a + a {
|
#partners a + a {
|
||||||
margin-left: 50px;
|
margin-left: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#homePage #partners img {
|
#partners img {
|
||||||
height: 80px;
|
height: 80px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -849,6 +884,11 @@ a:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 1024px) {
|
@media (min-width: 1024px) {
|
||||||
|
.row .col {
|
||||||
|
padding-left: 3rem;
|
||||||
|
padding-right: 3rem;
|
||||||
|
}
|
||||||
|
|
||||||
.nav-footer .footer-wrapper {
|
.nav-footer .footer-wrapper {
|
||||||
max-width: 1400px;
|
max-width: 1400px;
|
||||||
}
|
}
|
||||||
@ -904,20 +944,20 @@ a:hover {
|
|||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#homePage #partners #heading {
|
#partners #heading {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
word-wrap: normal;
|
word-wrap: normal;
|
||||||
width: auto;
|
width: auto;
|
||||||
margin-bottom: 50px;
|
margin-bottom: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#homePage #partners #list {
|
#partners #list {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#homePage #partners a + a {
|
#partners a + a {
|
||||||
margin: 25px auto;
|
margin: 25px auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -962,3 +1002,6 @@ a:hover {
|
|||||||
color: #a31515;
|
color: #a31515;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.badge {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
BIN
gitlab-pages/website/static/fonts/Inter-Black.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-Black.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-Black.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-Black.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-BlackItalic.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-BlackItalic.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-BlackItalic.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-BlackItalic.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-Bold.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-Bold.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-Bold.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-Bold.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-BoldItalic.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-BoldItalic.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-BoldItalic.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-BoldItalic.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-ExtraBold.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-ExtraBold.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-ExtraBold.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-ExtraBold.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-ExtraBoldItalic.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-ExtraBoldItalic.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-ExtraBoldItalic.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-ExtraBoldItalic.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-ExtraLight.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-ExtraLight.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-ExtraLight.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-ExtraLight.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-ExtraLightItalic.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-ExtraLightItalic.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-ExtraLightItalic.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-ExtraLightItalic.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-Italic.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-Italic.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-Italic.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-Italic.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-Light.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-Light.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-Light.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-Light.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-LightItalic.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-LightItalic.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-LightItalic.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-LightItalic.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-Medium.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-Medium.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-Medium.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-Medium.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-MediumItalic.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-MediumItalic.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-MediumItalic.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-MediumItalic.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-Regular.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-Regular.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-Regular.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-Regular.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-SemiBold.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-SemiBold.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-SemiBold.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-SemiBold.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-SemiBoldItalic.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-SemiBoldItalic.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-SemiBoldItalic.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-SemiBoldItalic.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-Thin.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-Thin.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-Thin.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-Thin.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-ThinItalic.woff
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-ThinItalic.woff
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-ThinItalic.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-ThinItalic.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-italic.var.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-italic.var.woff2
Normal file
Binary file not shown.
BIN
gitlab-pages/website/static/fonts/Inter-roman.var.woff2
Normal file
BIN
gitlab-pages/website/static/fonts/Inter-roman.var.woff2
Normal file
Binary file not shown.
16
gitlab-pages/website/static/fonts/inter.css
Normal file
16
gitlab-pages/website/static/fonts/inter.css
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
@font-face {
|
||||||
|
font-family: 'Inter var';
|
||||||
|
font-weight: 100 900;
|
||||||
|
font-display: swap;
|
||||||
|
font-style: normal;
|
||||||
|
font-named-instance: 'Regular';
|
||||||
|
src: url("./Inter-roman.var.woff2?v=3.12") format("woff2");
|
||||||
|
}
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Inter var';
|
||||||
|
font-weight: 100 900;
|
||||||
|
font-display: swap;
|
||||||
|
font-style: italic;
|
||||||
|
font-named-instance: 'Italic';
|
||||||
|
src: url("./Inter-italic.var.woff2?v=3.12") format("woff2");
|
||||||
|
}
|
27
gitlab-pages/website/static/img/circle.svg
Normal file
27
gitlab-pages/website/static/img/circle.svg
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<svg width="180" height="180" viewBox="0 0 180 180" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="180" height="180">
|
||||||
|
<path d="M180 90C180 139.706 139.706 180 90 180C40.2944 180 0 139.706 0 90C0 40.2944 40.2944 0 90 0C139.706 0 180 40.2944 180 90Z" fill="#C4C4C4"/>
|
||||||
|
</mask>
|
||||||
|
<g mask="url(#mask0)">
|
||||||
|
<path d="M0 0H89.8213C139.625 0 179.998 40.3736 179.998 90.1769V180H0V0Z" fill="#3AA0FF"/>
|
||||||
|
<mask id="mask1" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="180" height="180">
|
||||||
|
<path d="M0 0H89.8213C139.625 0 179.998 40.3736 179.998 90.1769V180H0V0Z" fill="#C4C4C4"/>
|
||||||
|
</mask>
|
||||||
|
<g mask="url(#mask1)">
|
||||||
|
<path d="M-97.3224 277.21L218.678 -38.7931L358.935 101.465L42.934 417.468L-97.3224 277.21Z" fill="#2888FF"/>
|
||||||
|
</g>
|
||||||
|
<path d="M63.2759 116.724V0H0V116.724V180H63.2759H179.998V116.724H63.2759Z" fill="#0E74FF"/>
|
||||||
|
<mask id="mask2" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="180" height="180">
|
||||||
|
<path d="M63.2759 116.724V0H0V116.724V180H63.2759H179.998V116.724H63.2759Z" fill="black"/>
|
||||||
|
</mask>
|
||||||
|
<g mask="url(#mask2)">
|
||||||
|
<path d="M-77.562 257.039L238.438 -58.9644L378.695 81.2934L62.6944 397.297L-77.562 257.039Z" fill="#0540FF"/>
|
||||||
|
</g>
|
||||||
|
<mask id="mask3" mask-type="alpha" maskUnits="userSpaceOnUse" x="90" y="0" width="90" height="91">
|
||||||
|
<path d="M90.0007 0.000366211C139.706 0.000366211 180 40.2952 180 90.0004H90.0007V0.000366211Z" fill="#AAA4A4"/>
|
||||||
|
</mask>
|
||||||
|
<g mask="url(#mask3)">
|
||||||
|
<path d="M125.584 -44.9172H224.893V54.3931H125.584V-44.9172Z" fill="#B4DBFF"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
31
gitlab-pages/website/static/img/logo-night.svg
Normal file
31
gitlab-pages/website/static/img/logo-night.svg
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<svg width="298" height="93" viewBox="0 0 298 93" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M197 0.0458624C195.572 1.53639 194.326 2.91226 193.011 4.24227C189.635 7.63609 186.236 11.007 182.904 14.4467C182.179 15.1805 181.477 15.5015 180.434 15.5015C170.757 15.4556 161.104 15.6391 151.427 15.4327C144.356 15.2493 138.374 17.7029 133.116 22.2891C127.972 26.7836 124.187 32.2413 122.578 39.006C121.377 44.0738 122.057 49.1186 123.371 54.0718C125.116 60.6072 128.244 66.3171 133.524 70.6052C139.507 75.4666 146.464 76.9113 153.92 76.5444C157.863 76.3609 161.738 75.8335 165.432 74.3659C165.772 74.2283 166.134 74.0678 166.474 73.9302C169.307 72.8524 170.757 71.2243 170.576 67.7388C170.214 61.1117 170.463 54.4387 170.463 47.7886C170.463 47.33 170.463 46.8943 170.463 46.344C175.086 46.344 179.596 46.344 184.241 46.344C184.264 46.7109 184.287 47.1236 184.287 47.5135C184.287 57.5344 184.309 67.5324 184.264 77.5533C184.264 78.1266 184.015 78.8375 183.629 79.2732C177.873 85.6939 170.758 89.7986 162.35 91.1745C151.268 92.986 140.345 92.0459 130.261 86.7488C117.91 80.2592 109.593 70.2153 106.715 56.2044C104.131 43.7298 105.695 31.7826 113.083 21.1884C120.425 10.663 130.374 3.76072 142.906 0.894317C145.24 0.366899 147.552 0.0458624 149.954 0.0458624C165.296 0.0687936 180.615 0.0229312 195.958 0C196.275 0.0458624 196.547 0.0458624 197 0.0458624Z" fill="white"/>
|
||||||
|
<path d="M75.2829 91.7477C75.2829 61.0658 75.2829 30.659 75.2829 0.137573C80.7897 0.137573 86.2512 0.137573 91.8487 0.137573C91.8714 0.481541 91.9167 0.894303 91.9167 1.28413C91.9167 25.4766 91.9167 49.669 91.9394 73.8614C91.9394 74.6411 91.7354 75.2143 91.1689 75.7647C86.1379 80.8325 81.107 85.9003 76.0987 90.991C75.8947 91.2203 75.6681 91.4038 75.2829 91.7477Z" fill="white"/>
|
||||||
|
<path d="M0.182086 0.0916748C5.349 0.0916748 10.4026 0.0916748 15.5695 0.0916748C15.5922 0.527368 15.6375 0.940129 15.6375 1.35289C15.6375 23.0917 15.6375 44.8534 15.6149 66.5922C15.6149 67.1425 15.4109 67.8305 15.0483 68.1973C10.2666 73.1046 5.43965 77.966 0.635324 82.8275C0.522014 82.9421 0.363381 83.0568 0.159424 83.2173C0.182086 55.4247 0.182086 27.7467 0.182086 0.0916748Z" fill="white"/>
|
||||||
|
<path d="M0 91.4267C0.362591 91.2432 0.815829 91.1286 1.11043 90.8534C6.11872 85.8315 11.1043 80.7637 16.1126 75.7418C16.4979 75.3519 17.1324 75.0309 17.631 75.0309C32.1346 75.008 46.6156 75.0309 61.1192 75.0309C61.3911 75.0309 61.6404 75.0538 62.0257 75.0767C62.0257 80.672 62.0257 86.2213 62.0257 91.8853C41.5166 91.8853 20.9396 91.8853 0.385253 91.8853C0.249281 91.7477 0.135971 91.5872 0 91.4267Z" fill="white"/>
|
||||||
|
<mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="210" y="0" width="88" height="88">
|
||||||
|
<circle cx="254" cy="44" r="44" fill="#C4C4C4"/>
|
||||||
|
</mask>
|
||||||
|
<g mask="url(#mask0)">
|
||||||
|
<path d="M209.984 0.000213623H253.985C278.285 0.000213623 297.985 19.6997 297.985 44.0002V88.0004H209.984V0.000213623Z" fill="white" fill-opacity="0.25"/>
|
||||||
|
<mask id="mask1" mask-type="alpha" maskUnits="userSpaceOnUse" x="209" y="0" width="89" height="89">
|
||||||
|
<path d="M209.984 0.000213623H253.985C278.285 0.000213623 297.985 19.6997 297.985 44.0002V88.0004H209.984V0.000213623Z" fill="#C4C4C4"/>
|
||||||
|
</mask>
|
||||||
|
<g mask="url(#mask1)">
|
||||||
|
<rect x="162.401" y="135.525" width="218.483" height="96.9736" transform="rotate(-45 162.401 135.525)" fill="white" fill-opacity="0.25"/>
|
||||||
|
</g>
|
||||||
|
<path d="M240.92 57.0652V0.000213623H209.984V57.0652V88.0004H240.92H297.985V57.0652H240.92Z" fill="white" fill-opacity="0.7"/>
|
||||||
|
<mask id="mask2" mask-type="alpha" maskUnits="userSpaceOnUse" x="209" y="0" width="89" height="89">
|
||||||
|
<path d="M240.92 57.0652V0.000213623H209.984V57.0652V88.0004H240.92H297.985V57.0652H240.92Z" fill="black"/>
|
||||||
|
</mask>
|
||||||
|
<g mask="url(#mask2)">
|
||||||
|
<rect x="172.059" y="125.664" width="218.483" height="96.9736" transform="rotate(-45 172.059 125.664)" fill="white"/>
|
||||||
|
</g>
|
||||||
|
<mask id="mask3" mask-type="alpha" maskUnits="userSpaceOnUse" x="253" y="0" width="45" height="45">
|
||||||
|
<path d="M253.983 0C278.284 0 297.983 19.6995 297.983 44.0001H253.983V0Z" fill="#AAA4A4"/>
|
||||||
|
</mask>
|
||||||
|
<g mask="url(#mask3)">
|
||||||
|
<rect x="271.376" y="-21.9596" width="48.5519" height="48.5519" fill="white"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.0 KiB |
52
gitlab-pages/website/static/img/logo-old.svg
Normal file
52
gitlab-pages/website/static/img/logo-old.svg
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<svg width="506" height="226" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<defs>
|
||||||
|
<style>.cls-1{isolation:isolate;}.cls-2{mix-blend-mode:screen;}.cls-3,.cls-4{fill:none;stroke-linecap:round;stroke-linejoin:round;}.cls-3{stroke:#b2210c;stroke-width:3px;}.cls-4{stroke:#fff;}.cls-5{fill:#fff;}.cls-6{opacity:0.56;mix-blend-mode:multiply;}.cls-7{fill:#333;}</style>
|
||||||
|
<image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAABUCAYAAACRBleVAAAACXBIWXMAAAsSAAALEgHS3X78AAAGeElEQVRoQ+2ZwW7cyBGG/7+6Sc7II2m1gLLZAD4EMHyQ4ZMfYPcl/Dxev078EvsCOQX2ITA2Bx+ChRaQVxpL4nR3/TmQlCjOjOQggz0E+gGiOc3q+rqKTYrqoiT8kbKHDHat/39gfMgAAEgSADbdbfatvnIx3AskSeEW9PbW/400XO5n9RB4a0oHWA/hO8BOunMbjpO+HwDfAhRus7FN3DghkkM0JwCPAf4T4NGL9QjP3kPPAZ0C+tBH+wYQtkS6BhwiQzdr+74HffkCe5I74NzBK+ucf4nQkyfws/fQvwG9ARyAtqX3zj2cpNG+B/j0GWz5O+wvCXZdYBffgAsAKwD7n6HDAP89g0+fwfER/rZLsQsQSU6hdyPsU3kC8Aywp89g5RLBVwjtAQwrhKh9XgucEcq8EGqU5hxuNUrYQ/n0EX4E+Icu2rXUrgEB8GfA/vEM4a89bLmHeJD3gzcessuig9mgaHRrrZzHi7K4RLYa5V97KC8/ovzYp3YKvFmlw+p6B3Af4MsMXiXYcg/xqF5ED6WWeW30pjVvjN7IvPZQ6qN6EZd7iFcJ9jJ349/1i266au/cw+ERwAtwfgbDPsLB9X5IKlWMXuVWVVXXZgIjodyuPFZMqQUOyr6u9i98eQ0/fQH/8B7DSt8c4dD7A4BF20W3lw/NGw9WKWarK1lVJ3gDeJPgjayqs9WVVYreeNjLh3aVYIsW/GHid9CdCE/65+15BtO34PmFh+ge90wx0CsFVcyKjKAypIDM7ILkrXvJ7uXJt8jztvNzcl+Eg169Ak4z2CbYbC6rG9gqVrGYKqcqN1WpqPb+dzFVq1jFuuns2wQ7zeCrV1PPnSJw52HHL9fg3MHsoFF0KUAKgAKp6IwVKToo8wwJBVAQFQJFCowO/nJ9+1YaP483EY5fzGcFrPyQUWAQGAVDQFCIIUiBjhikoBADAkIUrLdj5Yc8K7e+pi/8jS/v7/o2SCzemFWgSRYcll3Bgiy7QnCYSWYVWLyxIHE8fpPWgIu2m9Gli62DDQBKLAJdMkZQgjF2v4tASmwAtA5eegcd/Ey19c/TQd+mWswCDRULQArsIGBB158FproDDeO26Q7wuM/379611qfI+v7YnxOgARyeqeH6YD+MH/yNZcDmT4epskTXXQcuMPeQ+zT2/+BHlPWQasv1od+0Hs0mfdVH1F1FdHMmgPKA7boejHDXegTuXI/AnesRuHM9AneuR+DO9QjcuR6BO9cjcOd6BO5cj8Cd6xG4cz0IrNjtCaSbnozuX+2Mcf9g95AM2LC3MVLbt5GUTZwaodhv0w12mzT2fyfC036H49DuOvbRzocDCoCmfWP7Yfwp1qPemtJzAE5qmHoAJECBkNi3PRwA0Hb259sc9loDfpz8dlIi5ExSD/EePu732x3QjX4GrQH/3EC/AtgzKhtUEbJMN3aHF7oXuJfbPsv0ilA2aM+oX3s/67gR8M0o30cBSkYVUslaN8K9wFFQYCgwdm1B8QI3wpO13tlTR+HW19gv0O9ESRIm2/3JPity4VH0InoBS2TJKoF2s+ddchZLAD2SLtKTPmu6vTWuzqxtfZ3NIBi0MKgYfeXwOVaZqLKSzEIBXVSgVJBjxRyxylfoihozh5YGnc2go6lzTO7ha0D4e1fAmjfwq0s6EosKc3YmVraiuDJ1LStbZWdSYUZiubqkzxv4l9j5ef3QY/EWwHNA30Xo029QFc99Xln2ijmWlLIzJedqOLIzxZKSV8zzynIVz/3Tb93454DeTmlj4HADTwEtG2hWwa1BWV5b8WSZDVeNUls3uVXdtY1Sy4YrT5aX11asQZlV8GXT1RPHfm8402LXO8DGlbWwh2jXB5GNR2UPqZEFB4tBVUtntKLWss/Oc7lEHlfYXgO+tdg16AOgI8D/dAhf1PBwgeKz85xSSHEeVsHD6lpdG+dhlVJIPjvP4QJlUXfjhnLe1DcwiXBcHf0ZsNMXsOMvsOUKtjiCXbWwysGlgwuDknWLa3nWTe70Cfz4PfzHe6qk6zXgUdHyGODpi654tbyGzR2sR0WQVYCuDFrMuvt2/B4+1ILfYL12uBkIrEGHgvOmWsSygaaF520wYAtwXIsawMDmssCwGm9A6Iy21vMlbT0AUAB/AuwnwNQffwPCcD66RvQB3HdsTulIQ0n1Pqsh7K1RjfQgcKpxTfdrAFP918D/VQ9+te1afzjwPzXf9EBEGP37AAAAAElFTkSuQmCC" height="84" width="28" id="image"/>
|
||||||
|
<image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfkAAAAcCAYAAABiSMZhAAAACXBIWXMAAAsSAAALEgHS3X78AAAHBklEQVR4Xu3dy25b1xXG8f+39jmHuloRUKFpgAJGYXjgIKM8QJ7Cz+P4efISzQN4VNgDwwgKFEhTsICsiyWR5+y1OiBPJMikRKUetPH6AYIokdzU7NPal7UVEaSUUkrp98fue0FKKaWU/j81971gE5K06vc5R5BSSindbWWAAvEJptr10DHGQF/1rpfr/9aUUkopbeDFiogdw/Whwb9xyEvS+MoxzF8AP6wJ9qMM/JRSSmkj0zWT388hXi4fj+EvNg/7e0N+DPcx2J+B3oC+A96C+BYOr64D/ZcZerJusJRSSimt9A74cnId9sdbBK/gKcSPwDOIN8ugfwGxSdjfGfI3A/4Z6Aj0FnT4Ndqboe0BTQe07ei4oj/eeO+JZyWfUkopbeLArsP9X8BhIS6NOGqIy4Y4nxDHr4mnENNl2G8S9GtD/nbAH4Mdfo0+fMD+MMe6iq6+wNqKZgN24Qc6AC489GjliCmllFJa5xTYMcUJsGMnMWnwvhBb7/F5If7d4bu7+PFr4hB8k6BfX8lLuhnwf36CnV9hBz1W9yk+p8zrvm1th/U1rAlUIjRbVvAWkZV8SimltAFfbnubGFGlGES0RX51Ke/KmVtHLWfUkxbf28L/8Q6/GfQ8JOQl6fsbU/SXTyjnV9jRjPJ+lyb6/VI6bxiiRBel9bDqmMVEFqiPEJPFWBOgj5y6TymllG5qRczGH2bQSuEiXLMohvcm11yVRrXObVB7Vr/4wDCdUPe28O131HHq/vtFMf9RoK88J7+cpufNIujtaEDny4Bv5vuNdd705q1ZNBZd4xHFI8zaahEhAlVHLdCv+oCUUkrpM9fHoiNdD5SWZXoqvG9cIS+hGjYf3DRMWuTzfb3fPYMPsN0QU7A34MDaRfmPQn5ci19W8Vw+QecX2N4BdnW5X6zzxs27mHur0rWSNyIaEcUDcw8zWjVAv5yyb29/SEoppfSZG4vgZjlV30cfZvIGXKiGNKC2xHxu3iLrIPr92Ds48/MLbO8J8d07mC5P1UnS7Wp+ZSW/XIvnLagb0FcVXQwYW1F85kUWTVO61uWd99HKomnUFA+KFCJcApXlsTtf9SEppZTSZ6wsv2uxoB5SCQ+Fidoz1OhVrMia0qGhD3evbMlnA3Wnop8HNAcdLs7SixVn7e9sa/stcAZMHe04qgrRUao6U+8FRZFFI28at2jMKV7CAAVgGtfiP0n33JRSSul3ZADAl+EcIqziLkzeCBvA8Ygo3nZm0ZfiMRRHJ44eA/vAT+uGZ4P0nQ5oEujCEYa2BRZIgUIoQF4wHLOIxe8Da4DKGPJ3ntVPKaWUPlsFYgAErgg5siiYBRKMuSqAWSB8kcvTAe3fM/adIf8KeNoQUxE7RlQtvsQspDZisdgfqrgMD6RQhMArYL+GfG6uTymllFap41l3ESGFhFNxN0IQEhGaRWAxEVGMuNCiUc4r4PCOsT86QjduvPsB7Bise0z56pJysU07afbaelW7KNGFtV0j77xGWxUt0RSMIhbVvECeR+dSSimlO5kWBXOICBQ4FQ21hHor6oewubyfq2petsp8Npz3O5f0P29T53+nHoI/B1/VFOejSj4iAklvIL6DmO7i8zn2ocG3r6yeN1G74kPT97LSEk1E1HCilqLF7nrRKoBK7q5PKaWUVhl31y9WviGWu+tr4MiqGg3m6kvt+6HVMJfVR1dWP2zhTSF2d/HHED+Oa/qbnpMfTSH+8pr422P8qzPqye6pmtl+3wLqPBh6r3R1S1FmRLEeK21oiLoId2Uln1JKKa0yFsDjxrtWFtErXPhEqnNUS8wH6zS0gw3eW386Oa1HZ9Sft/FvXhM/3bPpbWXIL/fhB8BfWfy3cDIgzqjD/hk780dxUeQ74bVVP1wQpRUGE6lHLDveOdnxLqWUUlrldsc7SREiTLO4AN+WqsLqZVjdGWwYJqeVM+rJZNHD/gzi+SKrY+X5Oda0tV08c927/gg0/RrjhHLQY9N9yu6AbQ+P7HTLy0GgoYZdRajJ3vUppZTSg4y96wcjtqRoivxExKMrq5fNqX9o8KNl73oOqEev8Zu30T2odz1cb8C7HfR7MzReVDPeQtc6Ovcv1Hoob6FLKaWUHm68ha43xZ69j96I8Ra68WKa8wlxO+BXbbgbPeg++TegP7H6PnmAvFM+pZRSephVd8kDrLpP/p8QzzYMeLgn5OE66OE67AGOQG9BfAuHV9dh/ssMPVk5UkoppZTWeQd8ObkO/OMtglfwFGK6XHL/dXqe5f65e0L83pAf3Q57gBfAD6yv1o/ueC6llFJKi5Ns6557DvFy+fgh4T7aOORvuhn4N73MUE8ppZT+Ky9WhP5Dgv2m3xTyq0haGfCfZvSUUkrp92ddZfxbAn2VTxbyKaWUUvrf8h+PJeaRozTgTQAAAABJRU5ErkJggg==" height="28" width="505" id="image-2"/>
|
||||||
|
</defs>
|
||||||
|
<title>Plan de travail 2</title>
|
||||||
|
<g>
|
||||||
|
<title>background</title>
|
||||||
|
<rect fill="none" id="canvas_background" height="228" width="508" y="-1" x="-1"/>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<title>Layer 1</title>
|
||||||
|
<g stroke="null" id="svg_1" class="cls-1">
|
||||||
|
<g stroke="null" id="Calque_1">
|
||||||
|
<use stroke="null" id="svg_2" x="135" y="5" xlink:href="#image" class="cls-2"/>
|
||||||
|
<line stroke="null" id="svg_3" y2="75.18" x2="148.8" y1="19.19" x1="148.8" class="cls-3"/>
|
||||||
|
<use stroke="null" id="svg_4" x="135" y="5" xlink:href="#image" class="cls-2"/>
|
||||||
|
<line stroke="null" id="svg_5" y2="75.18" x2="148.8" y1="19.19" x1="148.8" class="cls-3"/>
|
||||||
|
<use stroke="null" id="svg_6" x="135" y="5" xlink:href="#image" class="cls-2"/>
|
||||||
|
<line stroke="null" id="svg_7" y2="75.18" x2="148.8" y1="19.19" x1="148.8" class="cls-3"/>
|
||||||
|
<line stroke="null" id="svg_8" y2="75.18" x2="148.8" y1="19.19" x1="148.8" class="cls-4"/>
|
||||||
|
<path stroke="null" id="svg_9" d="m157.89,171.21c-0.51,-19.43 0,-38.88 0,-58.33q0,-16.42 0,-32.86a9.31,9.31 0 0 0 -0.12,-1.75a8.8,8.8 0 0 0 -2.83,-5.16l-12.18,0a8.39,8.39 0 0 0 -2.95,6.56c-0.26,31.45 0.48,62.91 -0.37,94.36c-0.15,5.55 -0.06,11.12 0,16.68c0.1,10.35 0.25,20.69 0.39,31a6.46,6.46 0 0 0 0.11,0.84l17.66,0a3.71,3.71 0 0 0 0.13,-0.5c0.29,-5.92 -0.56,-11.88 0.51,-17.78c-0.3,-10.99 -0.06,-22.02 -0.35,-33.06zm-16.83,3.27q0,14.75 0,29.49a8,8 0 0 1 -0.08,0.84l-0.29,0.15c-0.17,-0.26 -0.46,-0.51 -0.48,-0.78c-0.06,-0.83 0,-1.67 0,-2.51l0,-27a3.59,3.59 0 0 1 0,-0.87a0.53,0.53 0 0 1 0.43,-0.32c0.13,0 0.32,0.2 0.38,0.35a1.82,1.82 0 0 1 0.04,0.65zm2.76,14.64l0,0c0,4.89 0,9.78 0,14.66a4,4 0 0 1 -0.41,1.13c-0.18,-0.39 -0.51,-0.78 -0.51,-1.17c0,-9.69 0,-19.38 0,-29.07a2.77,2.77 0 0 1 0.07,-0.87a0.56,0.56 0 0 1 0.45,-0.31a0.55,0.55 0 0 1 0.39,0.35a3.61,3.61 0 0 1 0,0.87l0.01,14.41zm2.69,15.14a2.77,2.77 0 0 1 -0.41,0.64a2.3,2.3 0 0 1 -0.46,-0.59a2.27,2.27 0 0 1 0,-0.74q0,-14.34 0,-28.69a5.41,5.41 0 0 1 0.41,-1.4a5.2,5.2 0 0 1 0.46,1.47c0,4.76 0,9.52 0,14.28l0,14.28a2.68,2.68 0 0 1 0,0.75zm1.82,0.6l0,-30.15a1.82,1.82 0 0 1 0,-0.62a3.14,3.14 0 0 1 0.43,-0.62a2.64,2.64 0 0 1 0.5,0.56a1.54,1.54 0 0 1 0,0.61q0,14.55 0,29.09c0.03,0.52 0.29,1.27 -0.93,1.13zm3.61,-0.5c-0.05,0.2 -0.26,0.36 -0.4,0.53a3.07,3.07 0 0 1 -0.43,-0.59a1.18,1.18 0 0 1 0,-0.5q0,-14.74 0,-29.48c0,-0.25 0,-0.49 0.05,-0.74l0.48,-0.18a4.65,4.65 0 0 1 0.32,1.11c0,2.42 0,4.85 0,7.27q0,10.86 0,21.71a3.6,3.6 0 0 1 -0.02,0.87zm-3.06,-80.62a3.59,3.59 0 0 1 -3.81,-3.86c0,-2.48 1.42,-4.19 3.61,-4.21s3.7,1.53 3.74,4s-1.34,4.03 -3.54,4.07zm5.87,51.09q0,14.41 0,28.84a4.83,4.83 0 0 1 -0.37,1.29l-0.47,-0.22l0,-31.52c0.41,0.36 0.71,0.51 0.82,0.74a2.29,2.29 0 0 1 0.02,0.87zm2.25,30.07a6.51,6.51 0 0 1 -0.44,-1.62c0,-4.72 0,-9.44 0,-14.16l0,0c0,-4.85 0,-9.7 0,-14.54a3.67,3.67 0 0 1 0.44,-1.11a3.33,3.33 0 0 1 0.44,1.09q0,14.35 0,28.71a6.59,6.59 0 0 1 -0.44,1.63z"/>
|
||||||
|
<path stroke="null" id="svg_10" d="m300.78,200.29c0,-5.58 0,-10.93 0,-16.28c0,-0.78 -0.39,-1 -1.1,-1c-0.5,0 -1,0 -1.5,0l-34.62,0c-1.33,0 -2.68,0.17 -3.75,-1a1.81,1.81 0 0 0 -1.19,-0.25c-1.1,0 -1.43,-0.53 -1.43,-1.56q0,-9.1 0,-18.2c0,-1 0.35,-1.38 1.4,-1.38q31.86,0 63.74,0c0.92,0 1.36,0.22 1.41,1.24a10.63,10.63 0 0 0 0.62,1.94a12.85,12.85 0 0 1 0.54,2.91q0,16.06 0,32.13q0,9.9 0,19.82c0,3.43 -0.51,3.94 -3.9,3.94l-44,0c-6,0 -12.05,0 -18.07,0a103.7,103.7 0 0 1 -21.33,-1.78a51.38,51.38 0 0 1 -6.67,-2.07c-2.43,-0.86 -4.85,-1.77 -7.24,-2.76a68.48,68.48 0 0 1 -16.37,-9.85a78.62,78.62 0 0 1 -21.08,-25c-6.06,-11.56 -8.49,-23.95 -8.15,-36.94c0.56,-21.44 9.08,-39.2 24.82,-53.61a70.56,70.56 0 0 1 41.19,-18.66c22.16,-2.32 41.76,3.7 58.68,18.3a71.67,71.67 0 0 1 14.15,16.48c2,3.25 3.64,6.75 5.36,10.18a23.89,23.89 0 0 1 1.56,4c0.52,1.83 0.05,2.39 -1.81,2.4c-5.52,0 -11,0.08 -16.56,-0.05a16.24,16.24 0 0 1 -4.27,-1.12c-0.26,-0.08 -0.46,-0.46 -0.61,-0.75a51.56,51.56 0 0 0 -14.2,-17a43.74,43.74 0 0 0 -14.31,-7.86c-5.47,-1.61 -11.05,-2.92 -16.81,-2.8c-6.07,0.13 -12.11,0.7 -17.85,2.91c-2.87,1.1 -5.89,2 -8.5,3.56a58.25,58.25 0 0 0 -9.51,6.65a75.66,75.66 0 0 0 -9.55,10.4a46.14,46.14 0 0 0 -5.07,9.16a51.88,51.88 0 0 0 -4.26,24.7a80.19,80.19 0 0 0 2.07,12.46c4,17.65 23.57,34.48 43,36.28c2.41,0.22 4.84,0.44 7.25,0.45c15.48,0 30.95,0 46.43,0l1.49,0.01zm21.35,-79.29c-0.2,-0.57 -0.33,-1 -0.49,-1.42a72.31,72.31 0 0 0 -35.14,-38.81c-18.54,-9.6 -37.94,-10.51 -57.7,-4.2c-10.83,3.46 -20,9.72 -28,17.75a72,72 0 0 0 -18.1,29.24a77.15,77.15 0 0 0 -2.79,32.87a68.53,68.53 0 0 0 8.25,25.48a76.63,76.63 0 0 0 13.65,17.54c13.84,13.45 30.42,20.43 49.69,20.59c23.13,0.18 46.26,0 69.39,0l1.44,0l0,-58.04l-63.78,0l0,18.46l1.69,0q20.14,0 40.28,0c1.18,0 1.61,0.31 1.58,1.55c-0.07,3.43 0,6.86 0,10.29c0,2.59 -0.06,5.19 0,7.78c0,1.24 -0.41,1.67 -1.59,1.53a8.34,8.34 0 0 0 -1,0q-23.52,0 -47.05,0c-10.68,0 -20.64,-2.66 -29.49,-8.73c-14.2,-9.71 -23.05,-22.83 -24.82,-40.21c-1.6,-15.78 2.29,-30 12.89,-42c14.33,-16.26 32.39,-22.2 53.46,-18c16.3,3.23 28.49,12.66 36.68,27.16a2.09,2.09 0 0 0 2.12,1.17c5.65,-0.07 11.29,0 16.94,0l1.89,0z"/>
|
||||||
|
<path stroke="null" id="svg_11" d="m414.43,71.41a74,74 0 0 1 32.77,7.29a75.65,75.65 0 0 1 18.74,13.07a79.13,79.13 0 0 1 13.88,17.23a55.39,55.39 0 0 1 4.16,8.11a135.48,135.48 0 0 1 4.65,13.56a62.43,62.43 0 0 1 1.88,14a76.21,76.21 0 0 1 -2.38,23.06a64.12,64.12 0 0 1 -5.81,15.15a62.78,62.78 0 0 1 -7.49,11.21c-2.39,2.67 -4.53,5.6 -7.17,8c-3.22,2.93 -6.37,6 -10.22,8.21c-2.17,1.23 -4.2,2.74 -6.41,3.9c-2.65,1.39 -5.4,2.58 -8.15,3.77c-6.85,3 -14.17,3.86 -21.49,4.48a84,84 0 0 1 -21.34,-1.4a65.91,65.91 0 0 1 -13.71,-4.43a70.43,70.43 0 0 1 -17.45,-10.23c-12.66,-10.12 -22.22,-22.5 -26.51,-38.31c-5.94,-21.91 -3.77,-42.94 8.76,-62.22c9.41,-14.47 22.27,-24.91 38.74,-30.58a74.65,74.65 0 0 1 24.55,-3.87zm73.57,74.92c0.62,-40.19 -33.55,-74 -74.14,-73.8c-40.06,0.19 -73.46,33.84 -73.41,74s34,74.53 75.53,73.65c38.53,-0.78 72.69,-33.27 72.02,-73.85z"/>
|
||||||
|
<path stroke="null" id="svg_12" d="m39.48,114.15c0,11.25 -0.13,22.51 0.06,33.75a89.79,89.79 0 0 0 1.46,12.3c1.52,9.67 6.63,17.41 13.35,24.26c10.42,10.63 23.08,15.79 37.9,15.83c6.2,0 12.39,0 18.58,0c1.19,0 2.1,0.11 2,1.63a1.11,1.11 0 0 0 0.15,0.73c1.38,1.62 0.94,3.56 1,5.4c0,3.93 0,7.87 0,11.8c0,1.93 -0.69,2.74 -2.64,2.72c-8.27,-0.08 -16.55,-0.1 -24.82,-0.46a62.2,62.2 0 0 1 -11.51,-1.69a68.29,68.29 0 0 1 -16.11,-6.34a78.65,78.65 0 0 1 -32.53,-31.59a67.67,67.67 0 0 1 -8.51,-28c-0.35,-4.25 -0.45,-8.52 -0.46,-12.78q-0.06,-33.94 0,-67.89c0,-2.4 0,-2.43 2.38,-2.43c5.69,0 11.38,0 17.07,0c1.12,0 1.78,0.24 1.66,1.51a1.21,1.21 0 0 0 0.17,0.84c1.17,1.25 1,2.81 1,4.27q0,18.08 0,36.14l-0.2,0zm-2.22,-41.47l-17.92,0c-0.93,0 -0.81,0.63 -0.81,1.21c0,24.84 0,49.68 0.13,74.52a68.76,68.76 0 0 0 6.72,29.47a75.53,75.53 0 0 0 19.7,25.19a68.33,68.33 0 0 0 41.82,16.77c7.88,0.39 15.8,0.18 23.7,0.23a4.11,4.11 0 0 0 0.7,-0.13l0,-18.39l-1.3,0c-5.9,0 -11.79,0 -17.69,0c-12.94,0 -24.53,-3.8 -34.55,-12.06c-13.08,-10.78 -20.41,-24.56 -20.57,-41.63c-0.22,-24.46 -0.07,-48.93 -0.08,-73.39l0.15,-1.79z"/>
|
||||||
|
<path stroke="null" id="svg_13" d="m152.83,119.62c0,2.47 -1.34,4.08 -3.55,4.12a3.59,3.59 0 0 1 -3.81,-3.86c0,-2.48 1.43,-4.19 3.61,-4.21s3.71,1.53 3.75,3.95z" class="cls-5"/>
|
||||||
|
<path stroke="null" id="svg_14" d="m146.93,189.23l0,14.28a2.35,2.35 0 0 1 0,0.75a2.77,2.77 0 0 1 -0.41,0.64a2.5,2.5 0 0 1 -0.45,-0.59a2.27,2.27 0 0 1 0,-0.74c0,-9.56 0,-19.13 0,-28.69a5,5 0 0 1 0.41,-1.4a5.55,5.55 0 0 1 0.46,1.47c0,4.76 -0.01,9.52 -0.01,14.28z" class="cls-5"/>
|
||||||
|
<path stroke="null" id="svg_15" d="m148.74,204.86l0,-30.15a1.82,1.82 0 0 1 0,-0.62a3.56,3.56 0 0 1 0.42,-0.62a2.44,2.44 0 0 1 0.51,0.56a1.54,1.54 0 0 1 0,0.61q0,14.55 0,29.09c0.03,0.52 0.33,1.27 -0.93,1.13z" class="cls-5"/>
|
||||||
|
<path stroke="null" id="svg_16" d="m144.23,189.12c0,4.89 0,9.78 0,14.66a3.65,3.65 0 0 1 -0.4,1.13c-0.18,-0.39 -0.52,-0.78 -0.52,-1.17q0,-14.53 0,-29.07a3.11,3.11 0 0 1 0.06,-0.87a0.59,0.59 0 0 1 0.45,-0.31a0.56,0.56 0 0 1 0.4,0.35a3.61,3.61 0 0 1 0,0.87c0,4.81 0,9.61 0,14.41l0.01,0z" class="cls-5"/>
|
||||||
|
<path stroke="null" id="svg_17" d="m154.31,204.74l0,-31.52c0.41,0.36 0.71,0.51 0.81,0.74a2.28,2.28 0 0 1 0,0.87q0,14.41 0,28.84a4.83,4.83 0 0 1 -0.37,1.29l-0.44,-0.22z" class="cls-5"/>
|
||||||
|
<path stroke="null" id="svg_18" d="m141.09,205c-0.17,-0.26 -0.47,-0.51 -0.49,-0.78c0,-0.83 0,-1.67 0,-2.51l0,-27a3.59,3.59 0 0 1 0,-0.87a0.53,0.53 0 0 1 0.42,-0.32c0.14,0 0.33,0.2 0.38,0.35a1.82,1.82 0 0 1 0,0.62l0,29.51a8,8 0 0 1 -0.08,0.84l-0.23,0.16z" class="cls-5"/>
|
||||||
|
<path stroke="null" id="svg_19" d="m152,173.4a4.65,4.65 0 0 1 0.32,1.11c0,2.42 0,4.85 0,7.27l0,21.71a3.59,3.59 0 0 1 0,0.87c-0.05,0.2 -0.26,0.36 -0.39,0.53a3.62,3.62 0 0 1 -0.44,-0.59a1.38,1.38 0 0 1 0,-0.5l0,-29.48c0,-0.25 0,-0.49 0.05,-0.74l0.46,-0.18z" class="cls-5"/>
|
||||||
|
<path stroke="null" id="svg_20" d="m157,189.12c0,-4.85 0,-9.7 0,-14.54a3.22,3.22 0 0 1 0.44,-1.11a3.57,3.57 0 0 1 0.44,1.09q0,14.35 0,28.71a6.21,6.21 0 0 1 -0.45,1.63a7,7 0 0 1 -0.44,-1.62c0,-4.72 0,-9.44 0,-14.16l0.01,0z" class="cls-5"/>
|
||||||
|
<path stroke="null" id="svg_21" d="m322.13,121l-1.89,0c-5.65,0 -11.29,0 -16.94,0a2.09,2.09 0 0 1 -2.12,-1.28c-8.19,-14.5 -20.38,-23.93 -36.68,-27.16c-21.07,-4.17 -39.13,1.77 -53.46,18c-10.6,12 -14.49,26.21 -12.89,42c1.77,17.38 10.62,30.5 24.82,40.21c8.85,6.07 18.81,8.71 29.49,8.73q23.52,0 47.05,0a8.34,8.34 0 0 1 1,0c1.18,0.14 1.63,-0.29 1.59,-1.53c-0.08,-2.59 0,-5.19 0,-7.78c0,-3.43 -0.05,-6.86 0,-10.29c0,-1.24 -0.4,-1.55 -1.58,-1.55q-20.14,0 -40.28,0l-1.69,0l0,-18.35l63.78,0l0,58.11l-1.44,0c-23.13,0 -46.26,0.14 -69.39,0c-19.27,-0.16 -35.85,-7.14 -49.69,-20.59a76.63,76.63 0 0 1 -13.65,-17.54a68.53,68.53 0 0 1 -8.25,-25.48a77.15,77.15 0 0 1 2.79,-32.87a72,72 0 0 1 18.1,-29.24c8,-8 17.17,-14.29 28,-17.75c19.76,-6.31 39.16,-5.4 57.7,4.2a72.31,72.31 0 0 1 35.14,38.81c0.16,0.35 0.29,0.77 0.49,1.35z" class="cls-5"/>
|
||||||
|
<path stroke="null" id="svg_22" d="m488,146.33c0.65,40.58 -33.51,73.07 -72,73.88c-41.54,0.88 -75.48,-33.46 -75.53,-73.65s33.35,-73.84 73.41,-74c40.59,-0.22 74.76,33.58 74.12,73.77zm-18.68,0c0.67,-29.77 -25.12,-55.42 -55.54,-55.17c-29.56,0.25 -55,25.15 -54.79,55.68c0.24,30.2 25.88,55.68 57.06,54.78c28.37,-0.77 53.89,-25.11 53.29,-55.24l-0.02,-0.05z" class="cls-5"/>
|
||||||
|
<path stroke="null" id="svg_23" d="m37.06,72.68l0,1.79c0,24.46 -0.14,48.93 0.08,73.39c0.16,17.07 7.49,30.85 20.57,41.63c10,8.26 21.61,12.1 34.55,12.06c5.9,0 11.79,0 17.69,0l1.35,0l0,18.38a4.11,4.11 0 0 1 -0.7,0.13c-7.9,-0.05 -15.82,0.16 -23.7,-0.23a68.33,68.33 0 0 1 -41.82,-16.77a75.53,75.53 0 0 1 -19.7,-25.19a68.76,68.76 0 0 1 -6.72,-29.47c-0.12,-24.84 -0.1,-49.68 -0.13,-74.52c0,-0.58 -0.12,-1.21 0.81,-1.21l17.72,0.01z" class="cls-5"/>
|
||||||
|
<path stroke="null" id="svg_24" d="m469.34,146.38c0.6,30.13 -24.92,54.47 -53.27,55.29c-31.18,0.9 -56.82,-24.58 -57.06,-54.78c-0.25,-30.53 25.23,-55.43 54.79,-55.68c30.42,-0.21 56.2,25.4 55.54,55.17zm-1,0c-0.42,-3.65 -0.64,-7.33 -1.31,-10.94a48.83,48.83 0 0 0 -11,-22.9a45.83,45.83 0 0 0 -28.97,-17.54a50.83,50.83 0 0 0 -9.66,-1.26a57.52,57.52 0 0 0 -20.64,3.43a49.8,49.8 0 0 0 -13.44,7.62a54,54 0 0 0 -14.51,16.39a47.87,47.87 0 0 0 -3.67,8.05a62,62 0 0 0 -2.95,11.22a74.21,74.21 0 0 0 -0.33,12.12a42.5,42.5 0 0 0 1.06,7.68c0.53,2.42 0.87,4.9 2.19,7.13c0.94,1.59 1.4,3.46 2.25,5.12a49.31,49.31 0 0 0 12.84,15.5c15.58,12.75 33.19,15.35 52,9.27c12.41,-4 21.66,-12.41 28.48,-23.41c5.21,-8.35 7.45,-17.61 7.65,-27.48l0.01,0z"/>
|
||||||
|
<use stroke="null" id="svg_26" y="5" xlink:href="#image-2" class="cls-2"/>
|
||||||
|
<line stroke="null" id="svg_27" y2="19.19" x2="490.59" y1="19.19" x1="14.32" class="cls-3"/>
|
||||||
|
<use stroke="null" id="svg_28" y="5" xlink:href="#image-2" class="cls-2"/>
|
||||||
|
<line stroke="null" id="svg_29" y2="19.19" x2="490.59" y1="19.19" x1="14.32" class="cls-3"/>
|
||||||
|
<use stroke="null" id="svg_30" y="5" xlink:href="#image-2" class="cls-2"/>
|
||||||
|
<line stroke="null" id="svg_31" y2="19.19" x2="490.59" y1="19.19" x1="14.32" class="cls-3"/>
|
||||||
|
<line stroke="null" id="svg_32" y2="19.19" x2="490.59" y1="19.19" x1="14.32" class="cls-4"/>
|
||||||
|
<image stroke="null" id="svg_33" x="111" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAE0AAAAqCAYAAAD2+NZSAAAACXBIWXMAAAsSAAALEgHS3X78AAACMUlEQVRoQ+3ay2vVQBQH4G/a6xPxiSBYcena/x9x407EnZviqi2IRVQo9pZ6c1xMoqXa9j7ymHvjD4YJJIHwcc5kc1JEgJRSktPs//MnAVFjpYhowK7hRr1vXfz+6FLhFCc4jYiY1DcmuIuneIxbMtyYqy5ksGMc4gDfcTqpq2wb9/ACL7GD28ZdcRV+YB/vcYSjlNLPSURESmmGaf3QdTzHM+OFa8D28Lm+nmJ2tj1n+IZd3MfDM2tscA3YIT7KVbYr+8zIZ5mIqFJKU7lvt86tMVVcJVfUAd7hdb0fYBoRFTUaRMQspXQsl+T5jAHubEu+xat638NxRMyaB3+jMWq4ucE4h8Yo4RYC4x9ojApuYTAuQGMUcEuBcQkaGw23NBhXoLGRcCuBMQcaGwW3MhhzorERcK2AsQAaaw3XGhgLorGWcK2CsQQaawXXOhhLorEWcJ2AsQIaRcN1BsaKaBQJ1ykYLaBRFFznYLSERhFwvYDRIhqDwvUGRstoDALXKxgdoNErXO9gdIRGL3CDgNEhGp3CDQZGx2h0AjcoGD2g0Src4GD0hEYrcEWA0SMaK8EVA0bPaCwFVxQYA6AxF1wzH1fJ82HFgDEQGlfC7eCmPIyyryAwBkTjUrgKj/BFntopBoyB0bgQ7kSutn28URAYBaDxF1zIo5pP8AkfZLwiwKinu0tJSmlbPsse4I6M91UeqCsCjMLQIKW0JXdA8/f8GfUEYikpDq1JSilFoR/3C863g5yMml6iAAAAAElFTkSuQmCC" height="42" width="77" class="cls-6"/>
|
||||||
|
<polygon stroke="null" id="svg_34" points="114.08999633789062,2.1500015258789062 183.50999450683594,2.2399978637695312 148.75999450683594,36.900001525878906 114.08999633789062,2.1500015258789062 " class="cls-5"/>
|
||||||
|
<path stroke="null" id="svg_35" d="m114.4,2.28l68.81,0.08l-34.45,34.36l-34.36,-34.44m-0.61,-0.25l0.43,0.42l34.36,34.45l0.18,0.18l0.18,-0.18l34.44,-34.36l0.43,-0.43l-0.6,0l-68.81,-0.11l-0.61,0.03z" class="cls-7"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 18 KiB |
@ -1,52 +1,38 @@
|
|||||||
<svg width="506" height="226" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
<svg width="400" height="123" viewBox="0 0 400 123" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<defs>
|
<mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="277" y="0" width="123" height="123">
|
||||||
<style>.cls-1{isolation:isolate;}.cls-2{mix-blend-mode:screen;}.cls-3,.cls-4{fill:none;stroke-linecap:round;stroke-linejoin:round;}.cls-3{stroke:#b2210c;stroke-width:3px;}.cls-4{stroke:#fff;}.cls-5{fill:#fff;}.cls-6{opacity:0.56;mix-blend-mode:multiply;}.cls-7{fill:#333;}</style>
|
<circle cx="338.48" cy="61.16" r="61" fill="#C4C4C4"/>
|
||||||
<image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAABUCAYAAACRBleVAAAACXBIWXMAAAsSAAALEgHS3X78AAAGeElEQVRoQ+2ZwW7cyBGG/7+6Sc7II2m1gLLZAD4EMHyQ4ZMfYPcl/Dxev078EvsCOQX2ITA2Bx+ChRaQVxpL4nR3/TmQlCjOjOQggz0E+gGiOc3q+rqKTYrqoiT8kbKHDHat/39gfMgAAEgSADbdbfatvnIx3AskSeEW9PbW/400XO5n9RB4a0oHWA/hO8BOunMbjpO+HwDfAhRus7FN3DghkkM0JwCPAf4T4NGL9QjP3kPPAZ0C+tBH+wYQtkS6BhwiQzdr+74HffkCe5I74NzBK+ucf4nQkyfws/fQvwG9ARyAtqX3zj2cpNG+B/j0GWz5O+wvCXZdYBffgAsAKwD7n6HDAP89g0+fwfER/rZLsQsQSU6hdyPsU3kC8Aywp89g5RLBVwjtAQwrhKh9XgucEcq8EGqU5hxuNUrYQ/n0EX4E+Icu2rXUrgEB8GfA/vEM4a89bLmHeJD3gzcessuig9mgaHRrrZzHi7K4RLYa5V97KC8/ovzYp3YKvFmlw+p6B3Af4MsMXiXYcg/xqF5ED6WWeW30pjVvjN7IvPZQ6qN6EZd7iFcJ9jJ349/1i266au/cw+ERwAtwfgbDPsLB9X5IKlWMXuVWVVXXZgIjodyuPFZMqQUOyr6u9i98eQ0/fQH/8B7DSt8c4dD7A4BF20W3lw/NGw9WKWarK1lVJ3gDeJPgjayqs9WVVYreeNjLh3aVYIsW/GHid9CdCE/65+15BtO34PmFh+ge90wx0CsFVcyKjKAypIDM7ILkrXvJ7uXJt8jztvNzcl+Eg169Ak4z2CbYbC6rG9gqVrGYKqcqN1WpqPb+dzFVq1jFuuns2wQ7zeCrV1PPnSJw52HHL9fg3MHsoFF0KUAKgAKp6IwVKToo8wwJBVAQFQJFCowO/nJ9+1YaP483EY5fzGcFrPyQUWAQGAVDQFCIIUiBjhikoBADAkIUrLdj5Yc8K7e+pi/8jS/v7/o2SCzemFWgSRYcll3Bgiy7QnCYSWYVWLyxIHE8fpPWgIu2m9Gli62DDQBKLAJdMkZQgjF2v4tASmwAtA5eegcd/Ey19c/TQd+mWswCDRULQArsIGBB158FproDDeO26Q7wuM/379611qfI+v7YnxOgARyeqeH6YD+MH/yNZcDmT4epskTXXQcuMPeQ+zT2/+BHlPWQasv1od+0Hs0mfdVH1F1FdHMmgPKA7boejHDXegTuXI/AnesRuHM9AneuR+DO9QjcuR6BO9cjcOd6BO5cj8Cd6xG4cz0IrNjtCaSbnozuX+2Mcf9g95AM2LC3MVLbt5GUTZwaodhv0w12mzT2fyfC036H49DuOvbRzocDCoCmfWP7Yfwp1qPemtJzAE5qmHoAJECBkNi3PRwA0Hb259sc9loDfpz8dlIi5ExSD/EePu732x3QjX4GrQH/3EC/AtgzKhtUEbJMN3aHF7oXuJfbPsv0ilA2aM+oX3s/67gR8M0o30cBSkYVUslaN8K9wFFQYCgwdm1B8QI3wpO13tlTR+HW19gv0O9ESRIm2/3JPity4VH0InoBS2TJKoF2s+ddchZLAD2SLtKTPmu6vTWuzqxtfZ3NIBi0MKgYfeXwOVaZqLKSzEIBXVSgVJBjxRyxylfoihozh5YGnc2go6lzTO7ha0D4e1fAmjfwq0s6EosKc3YmVraiuDJ1LStbZWdSYUZiubqkzxv4l9j5ef3QY/EWwHNA30Xo029QFc99Xln2ijmWlLIzJedqOLIzxZKSV8zzynIVz/3Tb93454DeTmlj4HADTwEtG2hWwa1BWV5b8WSZDVeNUls3uVXdtY1Sy4YrT5aX11asQZlV8GXT1RPHfm8402LXO8DGlbWwh2jXB5GNR2UPqZEFB4tBVUtntKLWss/Oc7lEHlfYXgO+tdg16AOgI8D/dAhf1PBwgeKz85xSSHEeVsHD6lpdG+dhlVJIPjvP4QJlUXfjhnLe1DcwiXBcHf0ZsNMXsOMvsOUKtjiCXbWwysGlgwuDknWLa3nWTe70Cfz4PfzHe6qk6zXgUdHyGODpi654tbyGzR2sR0WQVYCuDFrMuvt2/B4+1ILfYL12uBkIrEGHgvOmWsSygaaF520wYAtwXIsawMDmssCwGm9A6Iy21vMlbT0AUAB/AuwnwNQffwPCcD66RvQB3HdsTulIQ0n1Pqsh7K1RjfQgcKpxTfdrAFP918D/VQ9+te1afzjwPzXf9EBEGP37AAAAAElFTkSuQmCC" height="84" width="28" id="image"/>
|
</mask>
|
||||||
<image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfkAAAAcCAYAAABiSMZhAAAACXBIWXMAAAsSAAALEgHS3X78AAAHBklEQVR4Xu3dy25b1xXG8f+39jmHuloRUKFpgAJGYXjgIKM8QJ7Cz+P4efISzQN4VNgDwwgKFEhTsICsiyWR5+y1OiBPJMikRKUetPH6AYIokdzU7NPal7UVEaSUUkrp98fue0FKKaWU/j81971gE5K06vc5R5BSSindbWWAAvEJptr10DHGQF/1rpfr/9aUUkopbeDFiogdw/Whwb9xyEvS+MoxzF8AP6wJ9qMM/JRSSmkj0zWT388hXi4fj+EvNg/7e0N+DPcx2J+B3oC+A96C+BYOr64D/ZcZerJusJRSSimt9A74cnId9sdbBK/gKcSPwDOIN8ugfwGxSdjfGfI3A/4Z6Aj0FnT4Ndqboe0BTQe07ei4oj/eeO+JZyWfUkopbeLArsP9X8BhIS6NOGqIy4Y4nxDHr4mnENNl2G8S9GtD/nbAH4Mdfo0+fMD+MMe6iq6+wNqKZgN24Qc6AC489GjliCmllFJa5xTYMcUJsGMnMWnwvhBb7/F5If7d4bu7+PFr4hB8k6BfX8lLuhnwf36CnV9hBz1W9yk+p8zrvm1th/U1rAlUIjRbVvAWkZV8SimltAFfbnubGFGlGES0RX51Ke/KmVtHLWfUkxbf28L/8Q6/GfQ8JOQl6fsbU/SXTyjnV9jRjPJ+lyb6/VI6bxiiRBel9bDqmMVEFqiPEJPFWBOgj5y6TymllG5qRczGH2bQSuEiXLMohvcm11yVRrXObVB7Vr/4wDCdUPe28O131HHq/vtFMf9RoK88J7+cpufNIujtaEDny4Bv5vuNdd705q1ZNBZd4xHFI8zaahEhAlVHLdCv+oCUUkrpM9fHoiNdD5SWZXoqvG9cIS+hGjYf3DRMWuTzfb3fPYMPsN0QU7A34MDaRfmPQn5ci19W8Vw+QecX2N4BdnW5X6zzxs27mHur0rWSNyIaEcUDcw8zWjVAv5yyb29/SEoppfSZG4vgZjlV30cfZvIGXKiGNKC2xHxu3iLrIPr92Ds48/MLbO8J8d07mC5P1UnS7Wp+ZSW/XIvnLagb0FcVXQwYW1F85kUWTVO61uWd99HKomnUFA+KFCJcApXlsTtf9SEppZTSZ6wsv2uxoB5SCQ+Fidoz1OhVrMia0qGhD3evbMlnA3Wnop8HNAcdLs7SixVn7e9sa/stcAZMHe04qgrRUao6U+8FRZFFI28at2jMKV7CAAVgGtfiP0n33JRSSul3ZADAl+EcIqziLkzeCBvA8Ygo3nZm0ZfiMRRHJ44eA/vAT+uGZ4P0nQ5oEujCEYa2BRZIgUIoQF4wHLOIxe8Da4DKGPJ3ntVPKaWUPlsFYgAErgg5siiYBRKMuSqAWSB8kcvTAe3fM/adIf8KeNoQUxE7RlQtvsQspDZisdgfqrgMD6RQhMArYL+GfG6uTymllFap41l3ESGFhFNxN0IQEhGaRWAxEVGMuNCiUc4r4PCOsT86QjduvPsB7Bise0z56pJysU07afbaelW7KNGFtV0j77xGWxUt0RSMIhbVvECeR+dSSimlO5kWBXOICBQ4FQ21hHor6oewubyfq2petsp8Npz3O5f0P29T53+nHoI/B1/VFOejSj4iAklvIL6DmO7i8zn2ocG3r6yeN1G74kPT97LSEk1E1HCilqLF7nrRKoBK7q5PKaWUVhl31y9WviGWu+tr4MiqGg3m6kvt+6HVMJfVR1dWP2zhTSF2d/HHED+Oa/qbnpMfTSH+8pr422P8qzPqye6pmtl+3wLqPBh6r3R1S1FmRLEeK21oiLoId2Uln1JKKa0yFsDjxrtWFtErXPhEqnNUS8wH6zS0gw3eW386Oa1HZ9Sft/FvXhM/3bPpbWXIL/fhB8BfWfy3cDIgzqjD/hk780dxUeQ74bVVP1wQpRUGE6lHLDveOdnxLqWUUlrldsc7SREiTLO4AN+WqsLqZVjdGWwYJqeVM+rJZNHD/gzi+SKrY+X5Oda0tV08c927/gg0/RrjhHLQY9N9yu6AbQ+P7HTLy0GgoYZdRajJ3vUppZTSg4y96wcjtqRoivxExKMrq5fNqX9o8KNl73oOqEev8Zu30T2odz1cb8C7HfR7MzReVDPeQtc6Ovcv1Hoob6FLKaWUHm68ha43xZ69j96I8Ra68WKa8wlxO+BXbbgbPeg++TegP7H6PnmAvFM+pZRSephVd8kDrLpP/p8QzzYMeLgn5OE66OE67AGOQG9BfAuHV9dh/ssMPVk5UkoppZTWeQd8ObkO/OMtglfwFGK6XHL/dXqe5f65e0L83pAf3Q57gBfAD6yv1o/ueC6llFJKi5Ns6557DvFy+fgh4T7aOORvuhn4N73MUE8ppZT+Ky9WhP5Dgv2m3xTyq0haGfCfZvSUUkrp92ddZfxbAn2VTxbyKaWUUvrf8h+PJeaRozTgTQAAAABJRU5ErkJggg==" height="28" width="505" id="image-2"/>
|
<g mask="url(#mask0)">
|
||||||
</defs>
|
<path d="M277.48 0.160034H338.359C372.115 0.160034 399.479 27.5243 399.479 61.2799V122.16H277.48V0.160034Z" fill="#3AA0FF"/>
|
||||||
<title>Plan de travail 2</title>
|
<mask id="mask1" mask-type="alpha" maskUnits="userSpaceOnUse" x="277" y="0" width="123" height="123">
|
||||||
<g>
|
<path d="M277.48 0.160034H338.359C372.115 0.160034 399.479 27.5243 399.479 61.2799V122.16H277.48V0.160034Z" fill="#C4C4C4"/>
|
||||||
<title>background</title>
|
</mask>
|
||||||
<rect fill="none" id="canvas_background" height="228" width="508" y="-1" x="-1"/>
|
<g mask="url(#mask1)">
|
||||||
</g>
|
<rect width="302.895" height="134.44" transform="matrix(0.707103 -0.70711 0.707103 0.70711 211.518 188.047)" fill="#2888FF"/>
|
||||||
<g>
|
</g>
|
||||||
<title>Layer 1</title>
|
<path d="M320.367 79.2726V0.160034H277.48V79.2726V122.16H320.367H399.479V79.2726H320.367Z" fill="#0E74FF"/>
|
||||||
<g stroke="null" id="svg_1" class="cls-1">
|
<mask id="mask2" mask-type="alpha" maskUnits="userSpaceOnUse" x="277" y="0" width="123" height="123">
|
||||||
<g stroke="null" id="Calque_1">
|
<path d="M320.367 79.2726V0.160034H277.48V79.2726V122.16H320.367H399.479V79.2726H320.367Z" fill="black"/>
|
||||||
<use stroke="null" id="svg_2" x="135" y="5" xlink:href="#image" class="cls-2"/>
|
</mask>
|
||||||
<line stroke="null" id="svg_3" y2="75.18" x2="148.8" y1="19.19" x1="148.8" class="cls-3"/>
|
<g mask="url(#mask2)">
|
||||||
<use stroke="null" id="svg_4" x="135" y="5" xlink:href="#image" class="cls-2"/>
|
<rect width="302.895" height="134.44" transform="matrix(0.707103 -0.70711 0.707103 0.70711 224.911 174.376)" fill="#0540FF"/>
|
||||||
<line stroke="null" id="svg_5" y2="75.18" x2="148.8" y1="19.19" x1="148.8" class="cls-3"/>
|
</g>
|
||||||
<use stroke="null" id="svg_6" x="135" y="5" xlink:href="#image" class="cls-2"/>
|
<mask id="mask3" mask-type="alpha" maskUnits="userSpaceOnUse" x="338" y="0" width="62" height="62">
|
||||||
<line stroke="null" id="svg_7" y2="75.18" x2="148.8" y1="19.19" x1="148.8" class="cls-3"/>
|
<path d="M338.481 0.160156C372.17 0.160156 399.48 27.4711 399.48 61.1602H338.481V0.160156Z" fill="#AAA4A4"/>
|
||||||
<line stroke="null" id="svg_8" y2="75.18" x2="148.8" y1="19.19" x1="148.8" class="cls-4"/>
|
</mask>
|
||||||
<path stroke="null" id="svg_9" d="m157.89,171.21c-0.51,-19.43 0,-38.88 0,-58.33q0,-16.42 0,-32.86a9.31,9.31 0 0 0 -0.12,-1.75a8.8,8.8 0 0 0 -2.83,-5.16l-12.18,0a8.39,8.39 0 0 0 -2.95,6.56c-0.26,31.45 0.48,62.91 -0.37,94.36c-0.15,5.55 -0.06,11.12 0,16.68c0.1,10.35 0.25,20.69 0.39,31a6.46,6.46 0 0 0 0.11,0.84l17.66,0a3.71,3.71 0 0 0 0.13,-0.5c0.29,-5.92 -0.56,-11.88 0.51,-17.78c-0.3,-10.99 -0.06,-22.02 -0.35,-33.06zm-16.83,3.27q0,14.75 0,29.49a8,8 0 0 1 -0.08,0.84l-0.29,0.15c-0.17,-0.26 -0.46,-0.51 -0.48,-0.78c-0.06,-0.83 0,-1.67 0,-2.51l0,-27a3.59,3.59 0 0 1 0,-0.87a0.53,0.53 0 0 1 0.43,-0.32c0.13,0 0.32,0.2 0.38,0.35a1.82,1.82 0 0 1 0.04,0.65zm2.76,14.64l0,0c0,4.89 0,9.78 0,14.66a4,4 0 0 1 -0.41,1.13c-0.18,-0.39 -0.51,-0.78 -0.51,-1.17c0,-9.69 0,-19.38 0,-29.07a2.77,2.77 0 0 1 0.07,-0.87a0.56,0.56 0 0 1 0.45,-0.31a0.55,0.55 0 0 1 0.39,0.35a3.61,3.61 0 0 1 0,0.87l0.01,14.41zm2.69,15.14a2.77,2.77 0 0 1 -0.41,0.64a2.3,2.3 0 0 1 -0.46,-0.59a2.27,2.27 0 0 1 0,-0.74q0,-14.34 0,-28.69a5.41,5.41 0 0 1 0.41,-1.4a5.2,5.2 0 0 1 0.46,1.47c0,4.76 0,9.52 0,14.28l0,14.28a2.68,2.68 0 0 1 0,0.75zm1.82,0.6l0,-30.15a1.82,1.82 0 0 1 0,-0.62a3.14,3.14 0 0 1 0.43,-0.62a2.64,2.64 0 0 1 0.5,0.56a1.54,1.54 0 0 1 0,0.61q0,14.55 0,29.09c0.03,0.52 0.29,1.27 -0.93,1.13zm3.61,-0.5c-0.05,0.2 -0.26,0.36 -0.4,0.53a3.07,3.07 0 0 1 -0.43,-0.59a1.18,1.18 0 0 1 0,-0.5q0,-14.74 0,-29.48c0,-0.25 0,-0.49 0.05,-0.74l0.48,-0.18a4.65,4.65 0 0 1 0.32,1.11c0,2.42 0,4.85 0,7.27q0,10.86 0,21.71a3.6,3.6 0 0 1 -0.02,0.87zm-3.06,-80.62a3.59,3.59 0 0 1 -3.81,-3.86c0,-2.48 1.42,-4.19 3.61,-4.21s3.7,1.53 3.74,4s-1.34,4.03 -3.54,4.07zm5.87,51.09q0,14.41 0,28.84a4.83,4.83 0 0 1 -0.37,1.29l-0.47,-0.22l0,-31.52c0.41,0.36 0.71,0.51 0.82,0.74a2.29,2.29 0 0 1 0.02,0.87zm2.25,30.07a6.51,6.51 0 0 1 -0.44,-1.62c0,-4.72 0,-9.44 0,-14.16l0,0c0,-4.85 0,-9.7 0,-14.54a3.67,3.67 0 0 1 0.44,-1.11a3.33,3.33 0 0 1 0.44,1.09q0,14.35 0,28.71a6.59,6.59 0 0 1 -0.44,1.63z"/>
|
<g mask="url(#mask3)">
|
||||||
<path stroke="null" id="svg_10" d="m300.78,200.29c0,-5.58 0,-10.93 0,-16.28c0,-0.78 -0.39,-1 -1.1,-1c-0.5,0 -1,0 -1.5,0l-34.62,0c-1.33,0 -2.68,0.17 -3.75,-1a1.81,1.81 0 0 0 -1.19,-0.25c-1.1,0 -1.43,-0.53 -1.43,-1.56q0,-9.1 0,-18.2c0,-1 0.35,-1.38 1.4,-1.38q31.86,0 63.74,0c0.92,0 1.36,0.22 1.41,1.24a10.63,10.63 0 0 0 0.62,1.94a12.85,12.85 0 0 1 0.54,2.91q0,16.06 0,32.13q0,9.9 0,19.82c0,3.43 -0.51,3.94 -3.9,3.94l-44,0c-6,0 -12.05,0 -18.07,0a103.7,103.7 0 0 1 -21.33,-1.78a51.38,51.38 0 0 1 -6.67,-2.07c-2.43,-0.86 -4.85,-1.77 -7.24,-2.76a68.48,68.48 0 0 1 -16.37,-9.85a78.62,78.62 0 0 1 -21.08,-25c-6.06,-11.56 -8.49,-23.95 -8.15,-36.94c0.56,-21.44 9.08,-39.2 24.82,-53.61a70.56,70.56 0 0 1 41.19,-18.66c22.16,-2.32 41.76,3.7 58.68,18.3a71.67,71.67 0 0 1 14.15,16.48c2,3.25 3.64,6.75 5.36,10.18a23.89,23.89 0 0 1 1.56,4c0.52,1.83 0.05,2.39 -1.81,2.4c-5.52,0 -11,0.08 -16.56,-0.05a16.24,16.24 0 0 1 -4.27,-1.12c-0.26,-0.08 -0.46,-0.46 -0.61,-0.75a51.56,51.56 0 0 0 -14.2,-17a43.74,43.74 0 0 0 -14.31,-7.86c-5.47,-1.61 -11.05,-2.92 -16.81,-2.8c-6.07,0.13 -12.11,0.7 -17.85,2.91c-2.87,1.1 -5.89,2 -8.5,3.56a58.25,58.25 0 0 0 -9.51,6.65a75.66,75.66 0 0 0 -9.55,10.4a46.14,46.14 0 0 0 -5.07,9.16a51.88,51.88 0 0 0 -4.26,24.7a80.19,80.19 0 0 0 2.07,12.46c4,17.65 23.57,34.48 43,36.28c2.41,0.22 4.84,0.44 7.25,0.45c15.48,0 30.95,0 46.43,0l1.49,0.01zm21.35,-79.29c-0.2,-0.57 -0.33,-1 -0.49,-1.42a72.31,72.31 0 0 0 -35.14,-38.81c-18.54,-9.6 -37.94,-10.51 -57.7,-4.2c-10.83,3.46 -20,9.72 -28,17.75a72,72 0 0 0 -18.1,29.24a77.15,77.15 0 0 0 -2.79,32.87a68.53,68.53 0 0 0 8.25,25.48a76.63,76.63 0 0 0 13.65,17.54c13.84,13.45 30.42,20.43 49.69,20.59c23.13,0.18 46.26,0 69.39,0l1.44,0l0,-58.04l-63.78,0l0,18.46l1.69,0q20.14,0 40.28,0c1.18,0 1.61,0.31 1.58,1.55c-0.07,3.43 0,6.86 0,10.29c0,2.59 -0.06,5.19 0,7.78c0,1.24 -0.41,1.67 -1.59,1.53a8.34,8.34 0 0 0 -1,0q-23.52,0 -47.05,0c-10.68,0 -20.64,-2.66 -29.49,-8.73c-14.2,-9.71 -23.05,-22.83 -24.82,-40.21c-1.6,-15.78 2.29,-30 12.89,-42c14.33,-16.26 32.39,-22.2 53.46,-18c16.3,3.23 28.49,12.66 36.68,27.16a2.09,2.09 0 0 0 2.12,1.17c5.65,-0.07 11.29,0 16.94,0l1.89,0z"/>
|
<rect x="362.598" y="-30.2839" width="67.3097" height="67.3104" fill="#B4DBFF"/>
|
||||||
<path stroke="null" id="svg_11" d="m414.43,71.41a74,74 0 0 1 32.77,7.29a75.65,75.65 0 0 1 18.74,13.07a79.13,79.13 0 0 1 13.88,17.23a55.39,55.39 0 0 1 4.16,8.11a135.48,135.48 0 0 1 4.65,13.56a62.43,62.43 0 0 1 1.88,14a76.21,76.21 0 0 1 -2.38,23.06a64.12,64.12 0 0 1 -5.81,15.15a62.78,62.78 0 0 1 -7.49,11.21c-2.39,2.67 -4.53,5.6 -7.17,8c-3.22,2.93 -6.37,6 -10.22,8.21c-2.17,1.23 -4.2,2.74 -6.41,3.9c-2.65,1.39 -5.4,2.58 -8.15,3.77c-6.85,3 -14.17,3.86 -21.49,4.48a84,84 0 0 1 -21.34,-1.4a65.91,65.91 0 0 1 -13.71,-4.43a70.43,70.43 0 0 1 -17.45,-10.23c-12.66,-10.12 -22.22,-22.5 -26.51,-38.31c-5.94,-21.91 -3.77,-42.94 8.76,-62.22c9.41,-14.47 22.27,-24.91 38.74,-30.58a74.65,74.65 0 0 1 24.55,-3.87zm73.57,74.92c0.62,-40.19 -33.55,-74 -74.14,-73.8c-40.06,0.19 -73.46,33.84 -73.41,74s34,74.53 75.53,73.65c38.53,-0.78 72.69,-33.27 72.02,-73.85z"/>
|
</g>
|
||||||
<path stroke="null" id="svg_12" d="m39.48,114.15c0,11.25 -0.13,22.51 0.06,33.75a89.79,89.79 0 0 0 1.46,12.3c1.52,9.67 6.63,17.41 13.35,24.26c10.42,10.63 23.08,15.79 37.9,15.83c6.2,0 12.39,0 18.58,0c1.19,0 2.1,0.11 2,1.63a1.11,1.11 0 0 0 0.15,0.73c1.38,1.62 0.94,3.56 1,5.4c0,3.93 0,7.87 0,11.8c0,1.93 -0.69,2.74 -2.64,2.72c-8.27,-0.08 -16.55,-0.1 -24.82,-0.46a62.2,62.2 0 0 1 -11.51,-1.69a68.29,68.29 0 0 1 -16.11,-6.34a78.65,78.65 0 0 1 -32.53,-31.59a67.67,67.67 0 0 1 -8.51,-28c-0.35,-4.25 -0.45,-8.52 -0.46,-12.78q-0.06,-33.94 0,-67.89c0,-2.4 0,-2.43 2.38,-2.43c5.69,0 11.38,0 17.07,0c1.12,0 1.78,0.24 1.66,1.51a1.21,1.21 0 0 0 0.17,0.84c1.17,1.25 1,2.81 1,4.27q0,18.08 0,36.14l-0.2,0zm-2.22,-41.47l-17.92,0c-0.93,0 -0.81,0.63 -0.81,1.21c0,24.84 0,49.68 0.13,74.52a68.76,68.76 0 0 0 6.72,29.47a75.53,75.53 0 0 0 19.7,25.19a68.33,68.33 0 0 0 41.82,16.77c7.88,0.39 15.8,0.18 23.7,0.23a4.11,4.11 0 0 0 0.7,-0.13l0,-18.39l-1.3,0c-5.9,0 -11.79,0 -17.69,0c-12.94,0 -24.53,-3.8 -34.55,-12.06c-13.08,-10.78 -20.41,-24.56 -20.57,-41.63c-0.22,-24.46 -0.07,-48.93 -0.08,-73.39l0.15,-1.79z"/>
|
</g>
|
||||||
<path stroke="null" id="svg_13" d="m152.83,119.62c0,2.47 -1.34,4.08 -3.55,4.12a3.59,3.59 0 0 1 -3.81,-3.86c0,-2.48 1.43,-4.19 3.61,-4.21s3.71,1.53 3.75,3.95z" class="cls-5"/>
|
<g clip-path="url(#clip0)">
|
||||||
<path stroke="null" id="svg_14" d="m146.93,189.23l0,14.28a2.35,2.35 0 0 1 0,0.75a2.77,2.77 0 0 1 -0.41,0.64a2.5,2.5 0 0 1 -0.45,-0.59a2.27,2.27 0 0 1 0,-0.74c0,-9.56 0,-19.13 0,-28.69a5,5 0 0 1 0.41,-1.4a5.55,5.55 0 0 1 0.46,1.47c0,4.76 -0.01,9.52 -0.01,14.28z" class="cls-5"/>
|
<path d="M264 2.65315e-05C262.087 1.9766 260.416 3.80112 258.655 5.56483C254.13 10.0653 249.575 14.5354 245.11 19.0967C244.138 20.0698 243.197 20.4955 241.8 20.4955C228.832 20.4347 215.895 20.678 202.927 20.4043C193.452 20.161 185.435 23.4148 178.389 29.4965C171.495 35.4567 166.424 42.6939 164.267 51.6645C162.658 58.3849 163.569 65.0748 165.33 71.6431C167.669 80.3096 171.86 87.8814 178.936 93.5678C186.953 100.014 196.277 101.93 206.268 101.444C211.552 101.2 216.745 100.501 221.696 98.5549C222.151 98.3724 222.637 98.1596 223.093 97.9771C226.889 96.5479 228.832 94.3889 228.589 89.7667C228.104 80.9786 228.438 72.1296 228.438 63.3111C228.438 62.7029 228.438 62.1251 228.438 61.3953C234.633 61.3953 240.676 61.3953 246.902 61.3953C246.932 61.8819 246.963 62.4292 246.963 62.9462C246.963 76.2348 246.993 89.493 246.932 102.782C246.932 103.542 246.598 104.485 246.082 105.062C238.368 113.577 228.832 119.02 217.565 120.844C202.715 123.247 188.077 122 174.563 114.976C158.011 106.37 146.866 93.0509 143.009 74.4711C139.547 57.9287 141.642 42.0858 151.543 28.0369C161.382 14.0793 174.714 4.92625 191.509 1.12515C194.637 0.425749 197.734 2.65315e-05 200.953 2.65315e-05C221.513 0.0304353 242.043 -0.0303822 262.603 -0.060791C263.028 2.65315e-05 263.393 2.65315e-05 264 2.65315e-05Z" fill="black"/>
|
||||||
<path stroke="null" id="svg_15" d="m148.74,204.86l0,-30.15a1.82,1.82 0 0 1 0,-0.62a3.56,3.56 0 0 1 0.42,-0.62a2.44,2.44 0 0 1 0.51,0.56a1.54,1.54 0 0 1 0,0.61q0,14.55 0,29.09c0.03,0.52 0.33,1.27 -0.93,1.13z" class="cls-5"/>
|
<path d="M100.887 121.605C100.887 80.9177 100.887 40.5957 100.887 0.121643C108.266 0.121643 115.585 0.121643 123.087 0.121643C123.117 0.577775 123.178 1.12513 123.178 1.64208C123.178 33.7233 123.178 65.8046 123.208 97.8858C123.208 98.9197 122.935 99.68 122.176 100.41C115.434 107.13 108.692 113.85 101.98 120.601C101.707 120.905 101.403 121.149 100.887 121.605Z" fill="black"/>
|
||||||
<path stroke="null" id="svg_16" d="m144.23,189.12c0,4.89 0,9.78 0,14.66a3.65,3.65 0 0 1 -0.4,1.13c-0.18,-0.39 -0.52,-0.78 -0.52,-1.17q0,-14.53 0,-29.07a3.11,3.11 0 0 1 0.06,-0.87a0.59,0.59 0 0 1 0.45,-0.31a0.56,0.56 0 0 1 0.4,0.35a3.61,3.61 0 0 1 0,0.87c0,4.81 0,9.61 0,14.41l0.01,0z" class="cls-5"/>
|
<path d="M0.242939 0.060791C7.16713 0.060791 13.9395 0.060791 20.8637 0.060791C20.894 0.638558 20.9548 1.18592 20.9548 1.73327C20.9548 30.5608 20.9548 59.4187 20.9244 88.2462C20.9244 88.976 20.6511 89.8883 20.1652 90.3748C13.7573 96.8823 7.28861 103.329 0.850325 109.776C0.698478 109.928 0.485894 110.08 0.21257 110.293C0.242939 73.4372 0.242939 36.7338 0.242939 0.060791Z" fill="black"/>
|
||||||
<path stroke="null" id="svg_17" d="m154.31,204.74l0,-31.52c0.41,0.36 0.71,0.51 0.81,0.74a2.28,2.28 0 0 1 0,0.87q0,14.41 0,28.84a4.83,4.83 0 0 1 -0.37,1.29l-0.44,-0.22z" class="cls-5"/>
|
<path d="M0 121.179C0.485908 120.936 1.09329 120.784 1.48809 120.419C8.1997 113.759 14.8809 107.039 21.5925 100.379C22.1088 99.8624 22.9592 99.4367 23.6273 99.4367C43.0636 99.4063 62.4696 99.4367 81.9059 99.4367C82.2703 99.4367 82.6044 99.4671 83.1207 99.4975C83.1207 106.917 83.1207 114.276 83.1207 121.787C55.6365 121.787 28.0612 121.787 0.516277 121.787C0.334062 121.605 0.182216 121.392 0 121.179Z" fill="black"/>
|
||||||
<path stroke="null" id="svg_18" d="m141.09,205c-0.17,-0.26 -0.47,-0.51 -0.49,-0.78c0,-0.83 0,-1.67 0,-2.51l0,-27a3.59,3.59 0 0 1 0,-0.87a0.53,0.53 0 0 1 0.42,-0.32c0.14,0 0.33,0.2 0.38,0.35a1.82,1.82 0 0 1 0,0.62l0,29.51a8,8 0 0 1 -0.08,0.84l-0.23,0.16z" class="cls-5"/>
|
</g>
|
||||||
<path stroke="null" id="svg_19" d="m152,173.4a4.65,4.65 0 0 1 0.32,1.11c0,2.42 0,4.85 0,7.27l0,21.71a3.59,3.59 0 0 1 0,0.87c-0.05,0.2 -0.26,0.36 -0.39,0.53a3.62,3.62 0 0 1 -0.44,-0.59a1.38,1.38 0 0 1 0,-0.5l0,-29.48c0,-0.25 0,-0.49 0.05,-0.74l0.46,-0.18z" class="cls-5"/>
|
<defs>
|
||||||
<path stroke="null" id="svg_20" d="m157,189.12c0,-4.85 0,-9.7 0,-14.54a3.22,3.22 0 0 1 0.44,-1.11a3.57,3.57 0 0 1 0.44,1.09q0,14.35 0,28.71a6.21,6.21 0 0 1 -0.45,1.63a7,7 0 0 1 -0.44,-1.62c0,-4.72 0,-9.44 0,-14.16l0.01,0z" class="cls-5"/>
|
<clipPath id="clip0">
|
||||||
<path stroke="null" id="svg_21" d="m322.13,121l-1.89,0c-5.65,0 -11.29,0 -16.94,0a2.09,2.09 0 0 1 -2.12,-1.28c-8.19,-14.5 -20.38,-23.93 -36.68,-27.16c-21.07,-4.17 -39.13,1.77 -53.46,18c-10.6,12 -14.49,26.21 -12.89,42c1.77,17.38 10.62,30.5 24.82,40.21c8.85,6.07 18.81,8.71 29.49,8.73q23.52,0 47.05,0a8.34,8.34 0 0 1 1,0c1.18,0.14 1.63,-0.29 1.59,-1.53c-0.08,-2.59 0,-5.19 0,-7.78c0,-3.43 -0.05,-6.86 0,-10.29c0,-1.24 -0.4,-1.55 -1.58,-1.55q-20.14,0 -40.28,0l-1.69,0l0,-18.35l63.78,0l0,58.11l-1.44,0c-23.13,0 -46.26,0.14 -69.39,0c-19.27,-0.16 -35.85,-7.14 -49.69,-20.59a76.63,76.63 0 0 1 -13.65,-17.54a68.53,68.53 0 0 1 -8.25,-25.48a77.15,77.15 0 0 1 2.79,-32.87a72,72 0 0 1 18.1,-29.24c8,-8 17.17,-14.29 28,-17.75c19.76,-6.31 39.16,-5.4 57.7,4.2a72.31,72.31 0 0 1 35.14,38.81c0.16,0.35 0.29,0.77 0.49,1.35z" class="cls-5"/>
|
<rect width="264" height="122" fill="white"/>
|
||||||
<path stroke="null" id="svg_22" d="m488,146.33c0.65,40.58 -33.51,73.07 -72,73.88c-41.54,0.88 -75.48,-33.46 -75.53,-73.65s33.35,-73.84 73.41,-74c40.59,-0.22 74.76,33.58 74.12,73.77zm-18.68,0c0.67,-29.77 -25.12,-55.42 -55.54,-55.17c-29.56,0.25 -55,25.15 -54.79,55.68c0.24,30.2 25.88,55.68 57.06,54.78c28.37,-0.77 53.89,-25.11 53.29,-55.24l-0.02,-0.05z" class="cls-5"/>
|
</clipPath>
|
||||||
<path stroke="null" id="svg_23" d="m37.06,72.68l0,1.79c0,24.46 -0.14,48.93 0.08,73.39c0.16,17.07 7.49,30.85 20.57,41.63c10,8.26 21.61,12.1 34.55,12.06c5.9,0 11.79,0 17.69,0l1.35,0l0,18.38a4.11,4.11 0 0 1 -0.7,0.13c-7.9,-0.05 -15.82,0.16 -23.7,-0.23a68.33,68.33 0 0 1 -41.82,-16.77a75.53,75.53 0 0 1 -19.7,-25.19a68.76,68.76 0 0 1 -6.72,-29.47c-0.12,-24.84 -0.1,-49.68 -0.13,-74.52c0,-0.58 -0.12,-1.21 0.81,-1.21l17.72,0.01z" class="cls-5"/>
|
</defs>
|
||||||
<path stroke="null" id="svg_24" d="m469.34,146.38c0.6,30.13 -24.92,54.47 -53.27,55.29c-31.18,0.9 -56.82,-24.58 -57.06,-54.78c-0.25,-30.53 25.23,-55.43 54.79,-55.68c30.42,-0.21 56.2,25.4 55.54,55.17zm-1,0c-0.42,-3.65 -0.64,-7.33 -1.31,-10.94a48.83,48.83 0 0 0 -11,-22.9a45.83,45.83 0 0 0 -28.97,-17.54a50.83,50.83 0 0 0 -9.66,-1.26a57.52,57.52 0 0 0 -20.64,3.43a49.8,49.8 0 0 0 -13.44,7.62a54,54 0 0 0 -14.51,16.39a47.87,47.87 0 0 0 -3.67,8.05a62,62 0 0 0 -2.95,11.22a74.21,74.21 0 0 0 -0.33,12.12a42.5,42.5 0 0 0 1.06,7.68c0.53,2.42 0.87,4.9 2.19,7.13c0.94,1.59 1.4,3.46 2.25,5.12a49.31,49.31 0 0 0 12.84,15.5c15.58,12.75 33.19,15.35 52,9.27c12.41,-4 21.66,-12.41 28.48,-23.41c5.21,-8.35 7.45,-17.61 7.65,-27.48l0.01,0z"/>
|
</svg>
|
||||||
<use stroke="null" id="svg_26" y="5" xlink:href="#image-2" class="cls-2"/>
|
|
||||||
<line stroke="null" id="svg_27" y2="19.19" x2="490.59" y1="19.19" x1="14.32" class="cls-3"/>
|
|
||||||
<use stroke="null" id="svg_28" y="5" xlink:href="#image-2" class="cls-2"/>
|
|
||||||
<line stroke="null" id="svg_29" y2="19.19" x2="490.59" y1="19.19" x1="14.32" class="cls-3"/>
|
|
||||||
<use stroke="null" id="svg_30" y="5" xlink:href="#image-2" class="cls-2"/>
|
|
||||||
<line stroke="null" id="svg_31" y2="19.19" x2="490.59" y1="19.19" x1="14.32" class="cls-3"/>
|
|
||||||
<line stroke="null" id="svg_32" y2="19.19" x2="490.59" y1="19.19" x1="14.32" class="cls-4"/>
|
|
||||||
<image stroke="null" id="svg_33" x="111" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAE0AAAAqCAYAAAD2+NZSAAAACXBIWXMAAAsSAAALEgHS3X78AAACMUlEQVRoQ+3ay2vVQBQH4G/a6xPxiSBYcena/x9x407EnZviqi2IRVQo9pZ6c1xMoqXa9j7ymHvjD4YJJIHwcc5kc1JEgJRSktPs//MnAVFjpYhowK7hRr1vXfz+6FLhFCc4jYiY1DcmuIuneIxbMtyYqy5ksGMc4gDfcTqpq2wb9/ACL7GD28ZdcRV+YB/vcYSjlNLPSURESmmGaf3QdTzHM+OFa8D28Lm+nmJ2tj1n+IZd3MfDM2tscA3YIT7KVbYr+8zIZ5mIqFJKU7lvt86tMVVcJVfUAd7hdb0fYBoRFTUaRMQspXQsl+T5jAHubEu+xat638NxRMyaB3+jMWq4ucE4h8Yo4RYC4x9ojApuYTAuQGMUcEuBcQkaGw23NBhXoLGRcCuBMQcaGwW3MhhzorERcK2AsQAaaw3XGhgLorGWcK2CsQQaawXXOhhLorEWcJ2AsQIaRcN1BsaKaBQJ1ykYLaBRFFznYLSERhFwvYDRIhqDwvUGRstoDALXKxgdoNErXO9gdIRGL3CDgNEhGp3CDQZGx2h0AjcoGD2g0Src4GD0hEYrcEWA0SMaK8EVA0bPaCwFVxQYA6AxF1wzH1fJ82HFgDEQGlfC7eCmPIyyryAwBkTjUrgKj/BFntopBoyB0bgQ7kSutn28URAYBaDxF1zIo5pP8AkfZLwiwKinu0tJSmlbPsse4I6M91UeqCsCjMLQIKW0JXdA8/f8GfUEYikpDq1JSilFoR/3C863g5yMml6iAAAAAElFTkSuQmCC" height="42" width="77" class="cls-6"/>
|
|
||||||
<polygon stroke="null" id="svg_34" points="114.08999633789062,2.1500015258789062 183.50999450683594,2.2399978637695312 148.75999450683594,36.900001525878906 114.08999633789062,2.1500015258789062 " class="cls-5"/>
|
|
||||||
<path stroke="null" id="svg_35" d="m114.4,2.28l68.81,0.08l-34.45,34.36l-34.36,-34.44m-0.61,-0.25l0.43,0.42l34.36,34.45l0.18,0.18l0.18,-0.18l34.44,-34.36l0.43,-0.43l-0.6,0l-68.81,-0.11l-0.61,0.03z" class="cls-7"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.1 KiB |
@ -1,48 +0,0 @@
|
|||||||
---
|
|
||||||
id: version-next-api-cli-commands
|
|
||||||
title: CLI Commands
|
|
||||||
original_id: api-cli-commands
|
|
||||||
---
|
|
||||||
|
|
||||||
Contracts written in Ligo can be compiled using the `ligo` executable.
|
|
||||||
|
|
||||||
|
|
||||||
## Compiling a contract
|
|
||||||
|
|
||||||
Compile your contract with a specific entry point.
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
ligo compile-contract SOURCE_FILE [ENTRY_POINT]
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Example
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
ligo compile-contract examples/counter.ligo main
|
|
||||||
```
|
|
||||||
|
|
||||||
## Defining the initial storage
|
|
||||||
|
|
||||||
If your contract implements a sophisticated storage, you can compile a Ligo expression into a Michelson value quite easily.
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
ligo compile-storage SOURCE_FILE ENTRY_POINT EXPRESSION
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Example
|
|
||||||
```zsh
|
|
||||||
ligo compile-storage examples/counter.ligo main 5
|
|
||||||
# Outputs: 5
|
|
||||||
```
|
|
||||||
|
|
||||||
## Invoking the contract with a parameter
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
ligo compile-parameter SOURCE_FILE ENTRY_POINT EXPRESSION
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Example
|
|
||||||
```zsh
|
|
||||||
ligo compile-parameter examples/counter.ligo main "Increment(5)"
|
|
||||||
# Outputs: (Right 5)
|
|
||||||
```
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user