Jump to content

Conditional structures: Difference between revisions

m
→‎{{header|Retro}}: update for retro-11.0
m (→‎generic-inline-conditional: changed "works with" tag)
m (→‎{{header|Retro}}: update for retro-11.0)
Line 2,363:
 
=={{header|Retro}}==
===if-else-then, ifTrue, and ifFalse===
<lang Retro>( condition ) if ( true statements ) then
( condition ) if ( true statements ) else ( false statements ) then</lang>
 
Example:
 
<lang Retro>10 = if "TOS was equal to 10" puts else "TOS was not equal to 10" puts then cr</lang>
 
This model has the limitation of being usable only inside a definition.
 
===choose, ifTrue, and ifFalse===
<lang Retro>( condition ) [ ( true statements ) ] ifTrue
( condition ) [ ( false statements ) ] ifFalse
( condition ) [ ( true statements ) ] [ ( false statements ) ] chooseif</lang>
 
These forms can be used interactively, or inside function definitions.
 
===when===
<lang Retro>: foo ( n- )
[ 1 = ] [ drop ( if quote evaluates to true ) ] when
[ 2 = ] [ drop ( if quote evaluates to true ) ] when
[ 3 = ] [ drop ( if quote evaluates to true ) ] when
drop ( default action ) ;
 
=={{header|REXX}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.