fix "boolean-if-else.md"

This commit is contained in:
Lesenechal Remi 2019-12-25 23:38:37 +01:00
parent bddad3f234
commit 9a5800dc3e

View File

@ -11,18 +11,18 @@ Here's how to define a boolean:
<!--DOCUSAURUS_CODE_TABS--> <!--DOCUSAURUS_CODE_TABS-->
<!--Pascaligo--> <!--Pascaligo-->
```pascaligo ```pascaligo group=a
const a: bool = True; const a: bool = True;
const b: bool = False; const b: bool = False;
``` ```
<!--CameLIGO--> <!--CameLIGO-->
```cameligo ```cameligo group=a
let a: bool = true let a: bool = true
let b: bool = false let b: bool = false
``` ```
<!--ReasonLIGO--> <!--ReasonLIGO-->
```reasonligo ```reasonligo group=a
let a: bool = true; let a: bool = true;
let b: bool = false; let b: bool = false;
``` ```
@ -37,24 +37,24 @@ In LIGO, only values of the same type can be compared. We call these "comparable
<!--DOCUSAURUS_CODE_TABS--> <!--DOCUSAURUS_CODE_TABS-->
<!--Pascaligo--> <!--Pascaligo-->
```pascaligo ```pascaligo group=b
const a: string = "Alice"; const a: string = "Alice";
const b: string = "Alice"; const b: string = "Alice";
// True // True
const c: bool = (a = b); const c: bool = (a = b);
``` ```
<!--CameLIGO--> <!--CameLIGO-->
```cameligo ```cameligo group=b
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)
``` ```
<!--ReasonLIGO--> <!--ReasonLIGO-->
```reasonligo ```reasonligo group=b
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-->
@ -64,7 +64,7 @@ let c: bool = (a == b);
<!--DOCUSAURUS_CODE_TABS--> <!--DOCUSAURUS_CODE_TABS-->
<!--Pascaligo--> <!--Pascaligo-->
```pascaligo ```pascaligo group=c
const a: int = 5; const a: int = 5;
const b: int = 4; const b: int = 4;
const c: bool = (a = b); const c: bool = (a = b);
@ -75,7 +75,7 @@ const g: bool = (a >= b);
const h: bool = (a =/= b); const h: bool = (a =/= b);
``` ```
<!--CameLIGO--> <!--CameLIGO-->
```cameligo ```cameligo group=c
let a: int = 5 let a: int = 5
let b: int = 4 let b: int = 4
let c: bool = (a = b) let c: bool = (a = b)
@ -83,11 +83,11 @@ let d: bool = (a > b)
let e: bool = (a < b) let e: bool = (a < b)
let f: bool = (a <= b) 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)
``` ```
<!--ReasonLIGO--> <!--ReasonLIGO-->
```reasonligo ```reasonligo group=c
let a: int = 5; let a: int = 5;
let b: int = 4; let b: int = 4;
let c: bool = (a == b); let c: bool = (a == b);
@ -106,23 +106,23 @@ let h: bool = (a != b);
<!--DOCUSAURUS_CODE_TABS--> <!--DOCUSAURUS_CODE_TABS-->
<!--Pascaligo--> <!--Pascaligo-->
```pascaligo ```pascaligo group=d
const a: tez = 5mutez; const a: tez = 5mutez;
const b: tez = 10mutez; const b: tez = 10mutez;
const c: bool = (a = b); const c: bool = (a = b);
``` ```
<!--CameLIGO--> <!--CameLIGO-->
```cameligo ```cameligo group=d
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)
``` ```
<!--ReasonLIGO--> <!--ReasonLIGO-->
```reasonligo ```reasonligo group=d
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-->
@ -136,7 +136,7 @@ Conditional logic is an important part of every real world program.
<!--DOCUSAURUS_CODE_TABS--> <!--DOCUSAURUS_CODE_TABS-->
<!--Pascaligo--> <!--Pascaligo-->
```pascaligo ```pascaligo group=e
const min_age: nat = 16n; const min_age: nat = 16n;
(* (*
@ -162,7 +162,7 @@ function is_adult(const age: nat): bool is
> ``` > ```
<!--CameLIGO--> <!--CameLIGO-->
```cameligo ```cameligo group=e
let min_age: nat = 16n let min_age: nat = 16n
(** (**
@ -177,17 +177,17 @@ let is_adult (age: nat) : bool =
if (age > min_age) then true else false if (age > min_age) then true else false
``` ```
<!--ReasonLIGO--> <!--ReasonLIGO-->
```reasonligo ```reasonligo group=e
let min_age: nat = 16n; let min_age: nat = 16n;
/** (**
This function is really obnoxious, but it showcases This function is really obnoxious, but it showcases
how the if statement and it's syntax can be used. how the if statement and it's syntax can be used.
Normally, you'd use `with (age > min_age)` instead. Normally, you'd use `with (age > min_age)` instead.
*/ *)
let is_adult = (age: nat): bool => let is_adult = (age: nat): bool =>
if (age > min_age) { if (age > min_age) {