$ curl -sSL https://get.zenlang.org | sh $ zen --version Zen 1.0.0
fn main() { println("Hello, World!"); }
let x: Int = 5; // Explicitly typed let y = 10; // Type inferred var z = 15; // Mutable variable let pi: Float = 3.14159; let message: String = "Hello, Zen!"; let is_zen: Bool = true;
if x > 0 { println("Positive"); } else if x < 0 { println("Negative"); } else { println("Zero"); } for i in 0..5 { println(i); } while condition { // do something }
fn add(a: Int, b: Int) -> Int { a + b } let result = add(3, 4);
let result = match value { 0 => "Zero", n if n > 0 => "Positive", _ => "Negative", }
async fn fetch_data() -> Result{ // Asynchronous operations } async fn main() { let data = fetch_data().await?; println("Fetched: {data}"); }
fn identity(x: T) -> T { x } let int_val = identity(5); let str_val = identity("Hello");
use zen::ai::ethical; let decision = ethical::decide(action, context); if decision.is_ethical() { perform_action(action); } else { report_ethical_concern(decision.reason()); }
use zen::ai::nlp; let sentiment = nlp::analyze_sentiment(text); println("Sentiment: {sentiment}");
use zen::collections::Vector; let mut vec = Vector::new(); vec.push(1); vec.push(2); vec.push(3); for item in vec { println(item); }
use zen::io::File; let contents = File::read("example.txt")?; println("File contents: {contents}");
$ zen add network Adding network v1.2.3...
#[test] fn test_addition() { assert_eq!(add(2, 2), 4); } $ zen test Running 1 test... test test_addition ... ok Test result: ok. 1 passed; 0 failed
For more detailed information on each topic, please refer to the specific sections in the documentation.
Join the Zen Community | Try Zen Online