navid/haze / ef88b55c38bedae73348a2955374b9edda904b108bf9ea2269c110ba9778424c / samples/sample1.xyz
sample1.xyz
← samples · 488 bytes · raw · download
contract FactorialCond(n i32) {
pre {
n >= 0 &&
n <= 12
}
post r => {
r >= 1
}
}
// The ':' means "conforms to" in this scenario
fn factorial(n i32) i32 : FactorialCond(n) {
if n <= 1 {
return 1
}
return n * factorial(n - 1)
}
fn main(args list[str]) {
for arg in args {
print(arg)
}
const doubled = [1, 2, 3, 4, 5]
.map(fn(x) => x * 2)
.filter(fn(x) => x > 4)
print(doubled)
}