Merge branch 'fix-reasonligo-docs2' into 'dev'
Fix more ReasonLIGO docs issues See merge request ligolang/ligo!247
This commit is contained in:
commit
94b524c21c
@ -54,7 +54,7 @@ let c: bool = (a = b)
|
|||||||
```reasonligo
|
```reasonligo
|
||||||
let a: string = "Alice";
|
let a: string = "Alice";
|
||||||
let b: string = "Alice";
|
let b: string = "Alice";
|
||||||
// true
|
/* true */
|
||||||
let c: bool = (a == b);
|
let c: bool = (a == b);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
<!--END_DOCUSAURUS_CODE_TABS-->
|
||||||
@ -122,7 +122,7 @@ let c: bool = (a = b)
|
|||||||
```reasonligo
|
```reasonligo
|
||||||
let a: tez = 5mutez;
|
let a: tez = 5mutez;
|
||||||
let b: tez = 10mutez;
|
let b: tez = 10mutez;
|
||||||
// false
|
/* false */
|
||||||
let c: bool = (a == b);
|
let c: bool = (a == b);
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
<!--END_DOCUSAURUS_CODE_TABS-->
|
||||||
|
@ -80,7 +80,7 @@ along with a return type.
|
|||||||
Here's how you define a basic function that accepts two `ints` and returns an `int` as well:
|
Here's how you define a basic function that accepts two `ints` and returns an `int` as well:
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let add (a: int, b: int) : int = a + b;
|
let add = (a: int, b: int) : int => a + b;
|
||||||
```
|
```
|
||||||
|
|
||||||
The function body is a series of expressions, which are evaluated to give the return
|
The function body is a series of expressions, which are evaluated to give the return
|
||||||
|
@ -63,18 +63,18 @@ let g: int = 1_000_000
|
|||||||
<!--ReasonLIGO-->
|
<!--ReasonLIGO-->
|
||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
// int + int produces int
|
/* int + int produces int */
|
||||||
let a: int = 5 + 10;
|
let a: int = 5 + 10;
|
||||||
// nat + int produces int
|
/* nat + int produces int */
|
||||||
let b: int = 5n + 10;
|
let b: int = 5n + 10;
|
||||||
// tez + tez produces tez
|
/* tez + tez produces tez */
|
||||||
let c: tez = 5mutez + 10mutez;
|
let c: tez = 5mutez + 10mutez;
|
||||||
// you can't add tez + int or tez + nat, this won't compile
|
/* you can't add tez + int or tez + nat, this won't compile */
|
||||||
// let d: tez = 5mutez + 10n;
|
/* let d: tez = 5mutez + 10n; */
|
||||||
// two nats produce a nat
|
/* two nats produce a nat */
|
||||||
let e: nat = 5n + 10n;
|
let e: nat = 5n + 10n;
|
||||||
// nat + int produces an int, this won't compile
|
/* nat + int produces an int, this won't compile */
|
||||||
// let f: nat = 5n + 10;
|
/* let f: nat = 5n + 10; */
|
||||||
let g: int = 1_000_000;
|
let g: int = 1_000_000;
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -116,10 +116,10 @@ let d: tez = 5mutez - 1mt
|
|||||||
<!--ReasonLIGO-->
|
<!--ReasonLIGO-->
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let a: int = 5 - 10;
|
let a: int = 5 - 10;
|
||||||
// substraction of two nats, yields an int
|
/* substraction of two nats, yields an int */
|
||||||
let b: int = 5n - 2n;
|
let b: int = 5n - 2n;
|
||||||
// won't compile, result is an int, not a nat
|
/* won't compile, result is an int, not a nat */
|
||||||
// let c: nat = 5n - 2n;
|
/* let c: nat = 5n - 2n; */
|
||||||
let d: tez = 5mutez - 1mt;
|
let d: tez = 5mutez - 1mt;
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ let c: tez = 5n * 5mutez
|
|||||||
```reasonligo
|
```reasonligo
|
||||||
let a: int = 5 * 5;
|
let a: int = 5 * 5;
|
||||||
let b: nat = 5n * 5n;
|
let b: nat = 5n * 5n;
|
||||||
// you can also multiply `nat` and `tez`
|
/* you can also multiply `nat` and `tez` */
|
||||||
let c: tez = 5n * 5mutez;
|
let c: tez = 5n * 5mutez;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ let sum_of_a_list: int = List.fold sum my_list 0
|
|||||||
|
|
||||||
```reasonligo
|
```reasonligo
|
||||||
let sum = (result: int, i: int): int => result + i;
|
let sum = (result: int, i: int): int => result + i;
|
||||||
// Outputs 6
|
/* Outputs 6 */
|
||||||
let sum_of_a_list: int = List.fold(sum, my_list, 0);
|
let sum_of_a_list: int = List.fold(sum, my_list, 0);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ const a: string = "Hello Alice";
|
|||||||
let a: string = "Hello Alice"
|
let a: string = "Hello Alice"
|
||||||
```
|
```
|
||||||
<!--ReasonLIGO-->
|
<!--ReasonLIGO-->
|
||||||
```
|
```reasonligo
|
||||||
let a: string = "Hello Alice";
|
let a: string = "Hello Alice";
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
<!--END_DOCUSAURUS_CODE_TABS-->
|
||||||
|
@ -57,9 +57,9 @@ let ledger: account_balances = Map.literal
|
|||||||
[(("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address), 10mutez)]
|
[(("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address), 10mutez)]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--Reasonligo-->
|
<!--ReasonLIGO-->
|
||||||
```reasonligo
|
```reasonligo
|
||||||
// account_balances is a simple type, a map of address <-> tez
|
/* account_balances is a simple type, a map of address <-> tez */
|
||||||
type account_balances = map(address, tez);
|
type account_balances = map(address, tez);
|
||||||
|
|
||||||
let ledger: account_balances =
|
let ledger: account_balances =
|
||||||
@ -122,7 +122,7 @@ let ledger: account_balances = Map.literal
|
|||||||
)]
|
)]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--Reasonligo-->
|
<!--ReasonLIGO-->
|
||||||
```reasonligo
|
```reasonligo
|
||||||
/* alias two types */
|
/* alias two types */
|
||||||
type account = address;
|
type account = address;
|
||||||
@ -135,8 +135,8 @@ type account_data = {
|
|||||||
/* our ledger / account_balances is a map of account <-> account_data */
|
/* our ledger / account_balances is a map of account <-> account_data */
|
||||||
type account_balances = map(account, account_data);
|
type account_balances = map(account, account_data);
|
||||||
|
|
||||||
// pseudo-JSON representation of our map
|
/* pseudo-JSON representation of our map */
|
||||||
// {"tz1...": {balance: 10mutez, number_of_transactions: 5n}}
|
/* {"tz1...": {balance: 10mutez, number_of_transactions: 5n}} */
|
||||||
let ledger: account_balances =
|
let ledger: account_balances =
|
||||||
Map.literal([
|
Map.literal([
|
||||||
(
|
(
|
||||||
|
@ -5,8 +5,6 @@ title: Constants & Variables
|
|||||||
|
|
||||||
The next building block after types are constants and variables.
|
The next building block after types are constants and variables.
|
||||||
|
|
||||||
pleh.
|
|
||||||
|
|
||||||
## Constants
|
## Constants
|
||||||
|
|
||||||
Constants are immutable by design, which means their values can't be reassigned.
|
Constants are immutable by design, which means their values can't be reassigned.
|
||||||
|
@ -939,3 +939,18 @@ a:hover {
|
|||||||
width: 15em;
|
width: 15em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ReasonLIGO specific syntax highlighting */
|
||||||
|
.language-reasonligo .hljs-operator {
|
||||||
|
color: #a626a4;
|
||||||
|
}
|
||||||
|
.language-reasonligo .hljs-character {
|
||||||
|
color: #50a14f;
|
||||||
|
}
|
||||||
|
.language-reasonligo .hljs-module-identifier {
|
||||||
|
color: #4078f2;
|
||||||
|
}
|
||||||
|
.language-reasonligo .hljs-constructor {
|
||||||
|
color: #e45649;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user