Crates.io | graviton |
lib.rs | graviton |
version | 0.6.0 |
source | src |
created_at | 2019-07-31 23:08:10.380539 |
updated_at | 2020-02-20 03:42:53.318477 |
description | Graviton is a fast programming language that is minimal and simplistic with a simple and easy to read compiler. Everything is an expression unless a semicolon is used `;` then it becomes a statement which gives a clear distinction between expressions and statements. |
homepage | https://github.com/Ralakus/graviton |
repository | |
max_upload_size | |
id | 153296 |
size | 164,453 |
cargo build
Graviton is a fast programming language that is minimal and simplistic with a simple and easy to read compiler. Everything is an expression unless a semicolon is used ;
then it becomes a statement which gives a clear distinction between expressions and statements.
Graviton is still under heavy development so it is bound to have breaking changes
import "/std";
println("Iterative Fibonacci example");
let fib = (n: I32) {
let mut prevprevn = 0;
let mut prevn = 0;
let mut curn = 1;
let mut i = 2;
while i <= n {
prevprevn = prevn;
prevn = curn;
curn = prevprevn + prevn;
i = i + 1;
};
curn
};
print("Enter a number: ");
let n = read_num();
let fib_number: I32 = fib(n);
let output = if fib_number != fib(14) {
fib_number
} else {
println("Input was 14 so result will be negated for demonstration");
-fib_number
};
print("Fibonacci of ");
printn(n);
print(" is ");
printnln(fib(n));
println("");