RosettaCodeData/Task/Flow-control-structures/REXX/flow-control-structures-10.rexx
2014-01-17 05:34:36 +00:00

22 lines
1,021 B
Rexx

...
prod=1
a=7 /*or somesuch.*/
b=3 /* likewise. */
op='**' /*or whatever.*/
...
select
when op=='+' then r=a+b /*add. */
when op=='-' then r=a-b /*subtract. */
when op=='' then do; r=a*b; prod=prod*r; end /*multiply.*/
when op=='*' then r=a*b /*multiply. */
when op=='**' then r=a**b /*power (exponentiation) */
when op=='/' & b\=0 then r=a/b /*divide. */
when op=='%' & b\=0 then r=a/b /*interger divide. */
when op=='//' & b\=0 then r=a/b /*modulus (remainder). */
when op=='||' then r=a||b /*concatenation. */
when op=='caw' then r=xyz(a,b) /*call the XYZ subroutine*/
otherwise r='[n/a]' /*signify not applicable.*/
end /*select*/
say 'result for' a op b "=" r