Alpha. Vary is under active development and not ready for production use. Syntax, APIs, performance, and behaviour may change between releases.
Math
The math module provides integer math utilities. All functions operate on Int values unless noted.
from math import clamp_int, factorial, gcd
let clamped = clamp_int(150, 0, 100) # 100
let f = factorial(5) # 120
let g = gcd(12, 8) # 4
Clamping
from math import clamp_int, clamp_float
let a = clamp_int(-5, 0, 100) # 0
let b = clamp_int(50, 0, 100) # 50
let c = clamp_float(3.14, 0.0, 1.0) # 1.0
Sign and predicates
from math import sign, is_even, is_odd
print(sign(-42)) # -1
print(is_even(10)) # True
print(is_odd(7)) # True
Combinatorics
from math import factorial, gcd, lcm
let f = factorial(6) # 720
let g = gcd(48, 18) # 6
let l = lcm(4, 6) # 12