Control Flow¶
If / Elif / Else¶
let score be 85
if score >= 90 then
show "A"
elif score >= 80 then
show "B"
elif score >= 70 then
show "C"
else
show "F"
end
Comparison Operators¶
| Operator | Meaning |
|---|---|
== | Equal |
!= | Not equal |
> | Greater than |
< | Less than |
>= | Greater or equal |
<= | Less or equal |
is | Identity equal (same as ==) |
Logical Operators¶
let a be true
let b be false
if a and b then
show "both"
end
if a or b then
show "either" -- prints
end
if not b then
show "negated" -- prints
end
For Loops¶
Iterate over lists or ranges:
-- Range-based
for i in range(5) do
show i -- 0, 1, 2, 3, 4
end
-- List iteration
let fruits be ["apple", "banana", "cherry"]
for fruit in fruits do
show fruit
end
-- Range with start and end
for i in range(1, 4) do
show i -- 1, 2, 3
end
While Loops¶
Infinite Loop Protection
MOL limits loops to 1,000,000 iterations. If exceeded, a MOLRuntimeError is raised.
Blocks¶
Group statements in a scoped block:
Truthiness¶
The following values are falsy in MOL:
falsenull0""(empty string)[](empty list)
Everything else is truthy.