Crates.io | phoenix-lang |
lib.rs | phoenix-lang |
version | 1.5.3 |
source | src |
created_at | 2023-08-09 17:38:04.174497 |
updated_at | 2024-06-29 08:44:34.396896 |
description | A simple, fast programming language |
homepage | |
repository | https://github.com/TomtheCoder2/phoenix |
max_upload_size | |
id | 940218 |
size | 280,141 |
Based on the book Crafting Interpreters and this repo
Dynamic typing
Automatic memory management
Garbage collection
First-class functions
Closures
Lexical scoping
Tail recursion
Pattern matching
Algebraic data types
Inheritance
API for native functions written in Rust
cargo run -- --help
cargo install --path .
Then you can run phoenix with:
phoenix --help
fun binary_search(list, item) {
var low = 0;
var high = list.len() - 1;
while low <= high {
var mid = (low + high) / 2;
var guess = list[mid];
printf("low: {}, high: {}, mid: {}, guess: {}", low, high, mid, guess);
if guess == item {
return mid;
} else if guess > item {
high = mid - 1;
} else {
low = mid + 1;
}
}
return nil;
}
var elements = [1, 3, 5, 7, 9];
var search = 7;
printf("element {} is at index: {}", search, binary_search([1, 3, 5, 7, 9], 7));
c.l[0] = 1;
)[+-*/]=
, i++
and i--