update examples

This commit is contained in:
collin 2022-08-05 18:32:07 -07:00
parent d397c750d2
commit 667360905f
7 changed files with 12 additions and 1 deletions

View File

@ -16,6 +16,7 @@
// Note that the implementation below uses tuples instead of arrays.
// The implementation also manually unrolls the loop.
@program
function bubble_sort(
arr0: u32,
arr1: u32,

View File

@ -2,6 +2,7 @@
// Core circuit functions are built-in to the Leo language and call handwritten, optimized circuits in the AVM.
// To call a core circuit function, use the correct capitalized circuit identifier followed by two colons
// and then the function. Example: `Pedersen64::hash()`.
@program
function main(a: field) -> field {
let b: field = BHP256::hash(a);
let c: field = Poseidon2::hash(b);

View File

@ -1,5 +1,7 @@
// This function takes a group coordinate as input `a` and performs several operations which should output the `0group`.
// Note that the operations can be called as associated functions on the `a` variable.
@program
function main(a: group) -> group {
// unary
let e: group = a.double(); // 2a

View File

@ -1,7 +1,7 @@
import foo.leo;
// The 'helloworld' main function.
@program
function main(public a: u32, b: u32) -> u32 {
return a + b;
}

View File

@ -3,6 +3,7 @@
import point.leo;
// The main function.
@program
function main(public a: u32, b: u32) -> u32 {
return a + b;
}

View File

@ -11,6 +11,7 @@ circuit Message {
// The "main" function of this Leo program takes a "Message" circuit type as input.
// To see how to input variable "m" is passed in open up `inputs/message.in`.
@program
function main(m: Message) -> field {
// 1. Define the "Message" type.

View File

@ -1,3 +1,6 @@
// This example demonstrates an example of a minting and transferring a token in Leo.
// The `Token` record datatype.
record Token {
// The token owner.
owner: address,
@ -9,6 +12,7 @@ record Token {
// The `mint` function initializes a new record with the
// to the receiver of tokens in `r1` for the receiver in `r0`.
@program
function mint(owner: address, amount: u64) -> Token {
return Token {
owner: owner,
@ -19,6 +23,7 @@ function mint(owner: address, amount: u64) -> Token {
// The `transfer` function sends the specified number of tokens
// to the receiver from the provided token record.
@program
function transfer(token: Token, to: address, amount: u64) -> (Token, Token) {
// Checks the given token record has sufficient balance.