erg/tests/should_ok/control_expr.er
Shunsuke Shibayama 3c40fc35e9 fix: #193
and many bugs
2023-04-22 23:43:03 +09:00

59 lines
943 B
Python

i = if
i! = if!
f! = for!
w! = while!
cond = True
s = i cond:
do "then block"
do "else block"
assert s == "then block"
i! cond:
do!:
print! "then block!"
do!:
print! "else block!"
f! 0..<10, i =>
print! "i = \{i}"
counter = !10
print! counter
w! do!(not(counter == 0)), do!:
print! "counter = \{counter}"
counter.update!(i -> Nat(i - 1))
counter2 = !2
not_zero!() = not counter2 == 0
while! not_zero!, do!:
print! "aaa"
counter2.dec!()
ii = 0 + 2 * 3 / 2 ** 2
j = -+1
k = !0
if! ii >= 0:
do!:
i = 2
while! do!(k <= 2), do!:
print! k
for! [0, 1], i =>
print! i + k
k.inc!()
match! k:
0 => print! "zero"
_ => print! "\{k}"
match! k:
0 => print! "zero"
_ => print! "\{k}"
arrs = [[0, 1], [2, 3]]
for! arrs, arr =>
print! arr
for! arr, elem =>
print! elem