Anonymous user
Conditional structures: Difference between revisions
no edit summary
(Added formating) |
No edit summary |
||
Line 331:
including the ternary conditional
<lang awk>i=(i<0? 0: 42)</lang>
=={{header|Babel}}==
===Simple select===
<lang babel>
"foo" "bar" 3 4 > sel <<
</lang>
Prints "foo" since '3 4 >' evaluates to false, which causes sel to remove "bar" from the stack.
===If-Then-Else===
<lang babel>
{3 4 >}
{"foo"}
{"bar"}
ifte
<<
</lang>
Prints "bar" because the first line is the "if", the second line is the "then" and the last line is the "else", and '3 4 >' evaluates to false.
===Conditional===
<lang babel>
({3 4 >} {"Three is greater than four" }
{3 3 >} {"Three is greater than three"}
{3 2 >} {"Three is greater than two" }
{3 1 >} {"Three is greater than one" })
cond
<<
</lang>
Prints "Three is greater than two", as expected.
=={{header|BASIC}}==
|