You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Arithmetic
x + y # Addition
x - y # Subtraction
x * y # Multiplication
x / y # Division
# Engine (Zig) - Fast!
engine.list_sum([1.0, 2.0, 3.0])
engine.list_product([1.0, 2.0, 3.0])
engine.dot_product([1.0, 2.0], [3.0, 4.0])
engine.string_count("hello")
# Python Integration
python "math" "sqrt" (16.0)
python "numpy" "mean" ([1.0, 2.0, 3.0])
CLI Commands
# Run a file
mix zixir run file.zr
# Compile to binary
mix zixir compile file.zr
# Type check
mix zixir check file.zr
# Interactive REPL
mix zixir repl
# With options
mix zixir run file.zr --verbose --optimize release_fast
Elixir API
# Evaluate Zixir codeZixir.eval("engine.list_sum([1.0, 2.0])")# => {:ok, 3.0}# Run and return result (raises on error)Zixir.run("let x = 5\nx * 2")# => 10# Direct engine call (fastest)Zixir.run_engine(:list_sum,[[1.0,2.0,3.0]])# => 6.0# Direct Python callZixir.call_python("math","sqrt",[16.0])# => 4.0
Common Patterns
Pattern 1: Calculate Statistics
let data = [1.0, 2.0, 3.0, 4.0, 5.0]
let sum = engine.list_sum(data)
let product = engine.list_product(data)
let mean = python "numpy" "mean" (data)
[sum, product, mean]
Pattern 2: String Processing
let text = "Hello, World!"
let length = engine.string_count(text)
length
Pattern 3: Vector Math
let a = [1.0, 2.0, 3.0]
let b = [4.0, 5.0, 6.0]
engine.dot_product(a, b)
Pattern 4: Combine Operations
let x = engine.list_sum([1.0, 2.0])
let y = engine.string_count("hi")
x + y
File Extension
Use .zr for Zixir source files
Performance Tips
✅ Use engine.* for array math (fast Zig NIFs)
✅ Use arrays of floats [1.0, 2.0] not integers [1, 2] for engine ops
⚠️ Python calls have overhead - batch when possible