-
Notifications
You must be signed in to change notification settings - Fork 5
Examples of translation projections
dours edited this page May 5, 2022
·
6 revisions
The If-elif-else rule has only one alternative:
def f(cond1, a, cond2, b, e):
if cond1:
return a
elif cond2:
return b
else:
return c
[] > f
[xcond1NotCopied xaNotCopied xcond2NotCopied xbNotCopied xeNotCopied] > apply
[stackUp] > @
cage > tmp
xcond1NotCopied' > xcond1
xaNotCopied' > xa
xcond2NotCopied' > xcond2
xbNotCopied' > xb
xeNotCopied' > xe
seq > @
stdout "xf\n"
xcond1.<
xa.<
xcond2.<
xb.<
xe.<
(xcond1).if
seq
stackUp.forward (return (xa))
TRUE
seq
(xcond2).if
seq
stackUp.forward (return (xb))
TRUE
seq
stackUp.forward (return (xc))
TRUE
TRUE
123
https://github.com/polystat/py2eo/wiki/Tests-Structure#the-if-statement
def f(a, b):
try:
return a
finally:
return b
[] > f
[xaNotCopied xbNotCopied] > apply
[stackUp] > @
cage > tmp
xaNotCopied' > xa
xbNotCopied' > xb
seq > @
stdout "xf\n"
xa.<
xb.<
write.
xcurrent-exception
goto
[stackUp]
seq > @
stackUp.forward (return (xa))
stackUp.forward raiseNothing
seq
if.
xcurrent-exception.xclass.xid.eq (raiseNothing.xclass.xid)
seq
0
stackUp.forward (return (xb))
(xcurrent-exception.xclass.xid.neq (raiseNothing.xclass.xid)).if (stackUp.forward xcurrent-exception) 0
123
https://github.com/polystat/py2eo/wiki/Tests-Structure#the-try-statement