A vector-based language that transpiles to YOLOL.
What • Why • How • FAQ • License
Yovec is a specialized language for working with vectors (arrays of numbers).
Vectors are extremely useful in Starbase for navigation and targeting.
Complex YOLOL code can be difficult to understand.
Yovec has simple, declarative syntax that's friendly to beginners.
import n
let vector V = [$n, 2, 3]
let number A = V dot V
export A
YOLOL doesn't support arrays, so each array element must be a separate variable.
Yovec handles vector expansion so that you don't have to.
// YOLOL
v0=1 v1=2 v2=4 v3=8 v4=16 v5=32
// Yovec
let vector V = [1, 2, 4, 8, 16, 32]
YOLOL chips execute slowly and have a limited amount of space.
Yovec aggressively optimizes your code to make it faster and smaller.
# Without optimization: 255 characters
python3 yovec.py -i programs/axis.yovec --no-elim --no-reduce --no-mangle | wc -c
255
# With optimization: 105 characters
python3 yovec.py -i programs/axis.yovec | wc -c
105
Requires Git and Python 3.5+.
# Clone the repository
git clone https://github.com/averycrespi/yovec.git && cd yovec
# Install dependencies
pip3 install --user -r requirements.txt
# Run Yovec
python3 yovec.py --help
To learn the Yovec language, check out some example programs, follow the tutorial, or read the language specification.
Q: Why is the output of Yovec empty?
A: If no variables are exported, Yovec will eliminate the entire program. Export a variable or disable dead code elimination.
Q: Why are variables immutable?
A: Yovec uses single static assignment form. This restriction allows powerful optimization strategies.
Q: What's the difference between map
and apply
?
A: map
works with unary functions (e.g. map neg
), and with binary functions where one operand is "empty" (e.g. map 1+
). apply
works with binary functions where both operands are "empty" (e.g. apply +
)
Q: Why doesn't Yovec support conditionals?
A: YOLOL conditionals take up large amounts of space on a line. Evaluating a conditional for each element of a vector would quickly fill an entire chip.
Q: Why do indices have to be literals?
A: All indexing operations must be resolved at compile time. Variable indices would require conditionals.
Q: Why is there no filter
function?
A: filter
would return a vector of variable length. Variable-length vectors would require conditionals.