apiel
A subset of the APL programming language implemented in Rust. Evaluate APL expressions from Rust code through the apl! macro.
Usage
use apl;
// Evaluate APL expressions
let sum = apl!.unwrap; // [55.0]
let mat = apl!.unwrap; // [2.0, 3.0]
let fib = apl!.unwrap; // [55.0]
// Pass Rust data as ⍵ (right argument)
let result = apl!.unwrap; // [15.0]
// Pass both ⍺ (left) and ⍵ (right)
let result = apl!.unwrap; // [10.0, 20.0, 30.0]
// Shared environment -- variables persist across calls
let mut env = new;
apl!.unwrap;
apl!.unwrap;
let result = apl!.unwrap; // [55.0]
// Define and call named functions
apl!.unwrap;
apl!.unwrap; // [2.0, 4.0, 6.0]
What's Supported
- Arithmetic:
+-×÷*⍟○!?|⌈⌊⌹ - Arrays:
⍴,⌽⍉↑↓⍋⍒⊂⊃⊆⌷∪∩~⊣⊢≡≢⍷ - Comparison:
=≠<>≤≥∧∨⍲⍱ - Operators:
f/reduce,f\scan,∘.fouter product,f.ginner product,f¨each,f⍨commute,f⍣npower,{f}∘{g}compose,{f}⍥{g}over,{f}⍤krank,{f}@iat,{f}⌸key - Trains:
(f g h)fork,(f g)atop -- supports primitives, reductions, and named functions - Language:
←assignment,x+←1modified assignment,x[i]←vindexed assignment,{⍵}dfns,∇recursion,⋄:guards,¯high minus,'...'strings,⊥⊤encode/decode, nested arrays
Affiliation
Capstone project for the rustcamp by the Ukrainian Rust Community.