Merge branch 'bitwise-examples' into 'dev'
Bitwise pseudomodule examples. See merge request ligolang/ligo!670
This commit is contained in:
commit
5365f97f47
@ -9,17 +9,42 @@ import Syntax from '@theme/Syntax';
|
||||
import SyntaxTitle from '@theme/SyntaxTitle';
|
||||
|
||||
<SyntaxTitle syntax="pascaligo">
|
||||
function and : nat -> nat -> nat
|
||||
function and : 'a -> nat -> nat
|
||||
</SyntaxTitle>
|
||||
<SyntaxTitle syntax="cameligo">
|
||||
val and : nat -> nat -> nat
|
||||
val and : 'a -> nat -> nat
|
||||
</SyntaxTitle>
|
||||
<SyntaxTitle syntax="reasonligo">
|
||||
let and: (nat, nat) => nat
|
||||
let and: ('a, nat) => nat
|
||||
</SyntaxTitle>
|
||||
|
||||
`'a` can either be an `int` or `nat`.
|
||||
|
||||
A bitwise `and` operation.
|
||||
|
||||
<Syntax syntax="pascaligo">
|
||||
|
||||
```pascaligo
|
||||
const zero: nat = Bitwise.and(2n, 1n)
|
||||
```
|
||||
|
||||
</Syntax>
|
||||
<Syntax syntax="cameligo">
|
||||
|
||||
```cameligo
|
||||
let zero: nat = Bitwise.and 2n 1n
|
||||
```
|
||||
|
||||
</Syntax>
|
||||
<Syntax syntax="reasonligo">
|
||||
|
||||
```reasonligo
|
||||
let zero: nat = Bitwise.and(2n, 1n);
|
||||
```
|
||||
|
||||
</Syntax>
|
||||
|
||||
|
||||
<SyntaxTitle syntax="pascaligo">
|
||||
function or : nat -> nat -> nat
|
||||
</SyntaxTitle>
|
||||
@ -32,6 +57,28 @@ let or: (nat, nat) => nat
|
||||
|
||||
A bitwise `or` operation.
|
||||
|
||||
<Syntax syntax="pascaligo">
|
||||
|
||||
```pascaligo
|
||||
const three: nat = Bitwise.or(2n, 1n)
|
||||
```
|
||||
|
||||
</Syntax>
|
||||
<Syntax syntax="cameligo">
|
||||
|
||||
```cameligo
|
||||
let three: nat = Bitwise.or 2n 1n
|
||||
```
|
||||
|
||||
</Syntax>
|
||||
<Syntax syntax="reasonligo">
|
||||
|
||||
```reasonligo
|
||||
let three: nat = Bitwise.or(2n, 1n);
|
||||
```
|
||||
|
||||
</Syntax>
|
||||
|
||||
<SyntaxTitle syntax="pascaligo">
|
||||
function xor : nat -> nat -> nat
|
||||
</SyntaxTitle>
|
||||
@ -44,6 +91,28 @@ let xor: (nat, nat) => nat
|
||||
|
||||
A bitwise `xor` operation.
|
||||
|
||||
<Syntax syntax="pascaligo">
|
||||
|
||||
```pascaligo
|
||||
const three: nat = Bitwise.xor(2n, 1n)
|
||||
```
|
||||
|
||||
</Syntax>
|
||||
<Syntax syntax="cameligo">
|
||||
|
||||
```cameligo
|
||||
let three: nat = Bitwise.xor 2n 1n
|
||||
```
|
||||
|
||||
</Syntax>
|
||||
<Syntax syntax="reasonligo">
|
||||
|
||||
```reasonligo
|
||||
let three: nat = Bitwise.xor(2n, 1n);
|
||||
```
|
||||
|
||||
</Syntax>
|
||||
|
||||
<SyntaxTitle syntax="pascaligo">
|
||||
function shift_left : nat -> nat -> nat
|
||||
</SyntaxTitle>
|
||||
@ -56,6 +125,28 @@ let shift_left: (nat, nat) => nat
|
||||
|
||||
A bitwise shift left operation.
|
||||
|
||||
<Syntax syntax="pascaligo">
|
||||
|
||||
```pascaligo
|
||||
const four: nat = Bitwise.shift_left(2n, 1n)
|
||||
```
|
||||
|
||||
</Syntax>
|
||||
<Syntax syntax="cameligo">
|
||||
|
||||
```cameligo
|
||||
let four: nat = Bitwise.shift_left 2n 1n
|
||||
```
|
||||
|
||||
</Syntax>
|
||||
<Syntax syntax="reasonligo">
|
||||
|
||||
```reasonligo
|
||||
let four: nat = Bitwise.shift_left(2n, 1n);
|
||||
```
|
||||
|
||||
</Syntax>
|
||||
|
||||
<SyntaxTitle syntax="pascaligo">
|
||||
function shift_right : nat -> nat -> nat
|
||||
</SyntaxTitle>
|
||||
@ -67,3 +158,25 @@ let shift_right: (nat, nat) => nat
|
||||
</SyntaxTitle>
|
||||
|
||||
A bitwise shift right operation.
|
||||
|
||||
<Syntax syntax="pascaligo">
|
||||
|
||||
```pascaligo
|
||||
const one: nat = Bitwise.shift_right(2n, 1n)
|
||||
```
|
||||
|
||||
</Syntax>
|
||||
<Syntax syntax="cameligo">
|
||||
|
||||
```cameligo
|
||||
let one: nat = Bitwise.shift_right 2n 1n
|
||||
```
|
||||
|
||||
</Syntax>
|
||||
<Syntax syntax="reasonligo">
|
||||
|
||||
```reasonligo
|
||||
let one: nat = Bitwise.shift_right(2n, 1n);
|
||||
```
|
||||
|
||||
</Syntax>
|
Loading…
Reference in New Issue
Block a user