mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-22 22:44:47 +03:00
d31b707c4b
* improve leo example run scripts * add leo build warning message, reduce number of calls to snarkvm package open * cargo clippy * Update examples/token/run.sh Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com> Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> * Update examples/token/run.sh Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com> Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> * Update examples/token/run.sh Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com> Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> * Update examples/token/run.sh Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com> Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> * Update examples/token/run.sh Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com> Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> * fix comments * make auctioneer the starting private key in auction example --------- Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com> |
||
---|---|---|
.. | ||
build | ||
inputs | ||
src | ||
.env | ||
.gitignore | ||
program.json | ||
README.md | ||
run.sh |
A standard game of Tic-Tac-Toe in Leo.
⭕ ❕ ⭕ ❕ ❌
➖ ➕ ➖ ➕ ➖
⭕ ❕ ❌ ❕ ⭕
➖ ➕ ➖ ➕ ➖
❌ ❕ ❌ ❕ ⭕
Representing State
Leo allows users to define composite data types with the struct
keyword.
The game board is represented by a struct called Board
, which contains three Row
s.
An alternative representation would be to use an array, however, these are not yet supported in Leo.
Language Features
struct
declarations- conditional statements
- early termination. Leo allows users to return from a function early using the
return
keyword.
Running the Program
Leo provides users with a command line interface for compiling and running Leo programs.
Users may either specify input values via the command line or provide an input file in inputs/
.
Providing inputs via the command line.
- Run
leo run <function_name> <input_1> <input_2> ...
See ./run.sh
for an example.
Using an input file.
- Modify
inputs/tictactoe.in
with the desired inputs. - Run
leo run <function_name>
Executing the Program
leo execute <function_name> <input_1> <input_2> ...