RosettaCodeData/Task/Extend-your-language/M2000-Interpreter/extend-your-language.m2000

40 lines
931 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
module if2 {
over 3 : read &c
c=not (stackitem() and stackitem(2))
}
module ifelse1 {
over 3 : read &c
c=not (stackitem() and not stackitem(2))
}
module ifelse2 {
over 3 : read &c
c=not (stackitem(2) and not stackitem())
}
module ifelse {
over 3 : read &c
c=stackitem() or stackitem(2)
}
module endif2 {
if not empty then drop 3
}
ctrl=true
for a=1 to 2
for b=1 to 2
Print "a=";a, "b=";b
if2 a=1, b=2, &ctrl : Part {
print "both", a, b
} as ctrl
ifelse1 : Part {
print "first", a
} as ctrl
ifelse2 : Part {
print "second", b
} as ctrl
ifelse : part {
print "no one"
} as ctrl
endif2
next b
next a
Print "ok"