mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-24 18:52:58 +03:00
add import example, remove directory nesting, improve examples readme
This commit is contained in:
parent
1d734ffa3f
commit
bef473b656
13
examples/bubblesort/README.md
Normal file
13
examples/bubblesort/README.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# bubblesort
|
||||||
|
|
||||||
|
## Build Guide
|
||||||
|
|
||||||
|
To compile this program, run:
|
||||||
|
```bash
|
||||||
|
leo build
|
||||||
|
```
|
||||||
|
|
||||||
|
To run this program, run:
|
||||||
|
```bash
|
||||||
|
leo run
|
||||||
|
```
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"program": "bubblesort_tuple.aleo",
|
"program": "bubblesort.aleo",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"development": {
|
"development": {
|
@ -1,6 +1,13 @@
|
|||||||
# core.aleo
|
# Leo core functions
|
||||||
|
|
||||||
## Build Guide
|
## Build Guide
|
||||||
To compile this Aleo program, run:
|
|
||||||
|
To compile this program, run:
|
||||||
```bash
|
```bash
|
||||||
aleo build
|
leo build
|
||||||
|
```
|
||||||
|
|
||||||
|
To run this program, run:
|
||||||
|
```bash
|
||||||
|
leo run
|
||||||
```
|
```
|
@ -1,6 +1,13 @@
|
|||||||
# groups.aleo
|
# Leo group operations.
|
||||||
|
|
||||||
## Build Guide
|
## Build Guide
|
||||||
To compile this Aleo program, run:
|
|
||||||
|
To compile this program, run:
|
||||||
```bash
|
```bash
|
||||||
aleo build
|
leo build
|
||||||
|
```
|
||||||
|
|
||||||
|
To run this program, run:
|
||||||
|
```bash
|
||||||
|
leo run
|
||||||
```
|
```
|
@ -1,6 +1,13 @@
|
|||||||
# helloworld.aleo
|
# Leo helloworld
|
||||||
|
|
||||||
## Build Guide
|
## Build Guide
|
||||||
To compile this Aleo program, run:
|
|
||||||
|
To compile this program, run:
|
||||||
```bash
|
```bash
|
||||||
aleo build
|
leo build
|
||||||
|
```
|
||||||
|
|
||||||
|
To run this program, run:
|
||||||
|
```bash
|
||||||
|
leo run
|
||||||
```
|
```
|
8
examples/helloworld/imports/foo.leo
Normal file
8
examples/helloworld/imports/foo.leo
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
circuit Foo {
|
||||||
|
x: u64,
|
||||||
|
y: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
function bar(x: u64, y: u64) -> Foo {
|
||||||
|
return Foo {x, y};
|
||||||
|
}
|
@ -1,8 +1,7 @@
|
|||||||
|
import foo.leo;
|
||||||
|
|
||||||
// The 'helloworld' main function.
|
// The 'helloworld' main function.
|
||||||
|
|
||||||
function main(public a: u32, b: u32) -> u32 {
|
function main(public a: u32, b: u32) -> u32 {
|
||||||
return a + b;
|
return a + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
function foo(x: u64) -> u64 {
|
|
||||||
return x - x;
|
|
||||||
}
|
|
@ -1,6 +1,14 @@
|
|||||||
# message.aleo
|
# Leo message circuit
|
||||||
|
A basic example showing how to declare a circuit in the Leo language.
|
||||||
|
|
||||||
## Build Guide
|
## Build Guide
|
||||||
To compile this Aleo program, run:
|
|
||||||
|
To compile this program, run:
|
||||||
```bash
|
```bash
|
||||||
aleo build
|
leo build
|
||||||
|
```
|
||||||
|
|
||||||
|
To run this program, run:
|
||||||
|
```bash
|
||||||
|
leo run
|
||||||
```
|
```
|
2
examples/point/.gitignore
vendored
Normal file
2
examples/point/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
outputs/
|
||||||
|
build/
|
14
examples/point/README.md
Normal file
14
examples/point/README.md
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Leo import example
|
||||||
|
An example showing how to import symbols from file `point.leo`.
|
||||||
|
|
||||||
|
## Build Guide
|
||||||
|
|
||||||
|
To compile this program, run:
|
||||||
|
```bash
|
||||||
|
leo build
|
||||||
|
```
|
||||||
|
|
||||||
|
To run this program, run:
|
||||||
|
```bash
|
||||||
|
leo run
|
||||||
|
```
|
16
examples/point/imports/point.leo
Normal file
16
examples/point/imports/point.leo
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// A (x, y) coordinate point
|
||||||
|
circuit Point {
|
||||||
|
x: u32,
|
||||||
|
y: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
function new(x: u32, y: u32) -> Point {
|
||||||
|
return Point {x, y};
|
||||||
|
}
|
||||||
|
|
||||||
|
function add(a: Point, b: Point) -> Point {
|
||||||
|
return Point {
|
||||||
|
x: a.x + b.x,
|
||||||
|
y: a.y + b.y,
|
||||||
|
}
|
||||||
|
}
|
7
examples/point/inputs/point.in
Normal file
7
examples/point/inputs/point.in
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// The program input for point/src/main.leo
|
||||||
|
[main]
|
||||||
|
public a: u32 = 1u32;
|
||||||
|
b: u32 = 2u32; // Input variable `b` is private by default.
|
||||||
|
|
||||||
|
[foo]
|
||||||
|
x: u64 = 5u64;
|
10
examples/point/program.json
Normal file
10
examples/point/program.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"program": "helloworld.aleo",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "",
|
||||||
|
"development": {
|
||||||
|
"private_key": "APrivateKey1zkpBvXdKZKaXXcLUnwAVFCQNp41jrX6JqTuJo1JShfPoRfx",
|
||||||
|
"address": "aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau"
|
||||||
|
},
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
8
examples/point/src/main.leo
Normal file
8
examples/point/src/main.leo
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Import the circuits and functions from `imports/point.leo`.
|
||||||
|
// In testnet3, Leo imports all symbols from a file by default.
|
||||||
|
import point.leo;
|
||||||
|
|
||||||
|
// The 'point' main function.
|
||||||
|
function main(public a: u32, b: u32) -> u32 {
|
||||||
|
return a + b;
|
||||||
|
}
|
@ -1,8 +0,0 @@
|
|||||||
# bubblesort_tuple.aleo
|
|
||||||
|
|
||||||
## Build Guide
|
|
||||||
|
|
||||||
To compile this Aleo program, run:
|
|
||||||
```bash
|
|
||||||
aleo build
|
|
||||||
```
|
|
@ -1,6 +1,13 @@
|
|||||||
# token.aleo
|
# token
|
||||||
|
|
||||||
## Build Guide
|
## Build Guide
|
||||||
To compile this Aleo program, run:
|
|
||||||
|
To compile this program, run:
|
||||||
```bash
|
```bash
|
||||||
aleo build
|
leo build
|
||||||
|
```
|
||||||
|
|
||||||
|
To run this program, run:
|
||||||
|
```bash
|
||||||
|
leo run
|
||||||
```
|
```
|
Loading…
Reference in New Issue
Block a user