Conditional structures: Difference between revisions

Add Seed7 example
(Added Deluge.)
(Add Seed7 example)
Line 2,720:
<lang>composite
consonant</lang>
=={{header|Slate}}==
 
=={{header|Seed7}}==
===ifTrue/ifFalse===
===if-else ifthen-else===
There can be single or multiple statements. An if-statement can have multiple elsif parts.
<lang seed7>if condition then
statement
end if</lang>;
 
if condition then
statement1
else
statement2;
end if;
 
if condition1 then
statement1
elsif condition2 then
statement2;
end if;
 
if condition1 then
statement1
elsif condition2 then
statement2;
else
statement3;
end if;</lang>
 
=== case ===
<lang seed7>case i of
when {1, 4, 9}: # Executed if i is 1, 4 or 9
statement1;
when {11} | {13 .. 17}: # Executed if i is 11, 13, 14, 15, 16 or 17
statement2;
when {42}: # Executed only if i is 42
statement3;
otherwise:
statement4;
end case;</lang>
 
=={{header|SIMPOL}}==
===if-else if-else===
<lang simpol>if x == 1
foo()
else if x == 2
bar()
else
foobar()
end if</lang>
 
===ternary if function===
<lang simpol>.if(x == 1, "hello", "world")</lang>
 
=={{header|Slate}}==
===ifTrue/ifFalse===
<lang slate>"Conditionals in Slate are really messages sent to Boolean objects. Like Smalltalk. (But the compiler might optimize some cases)"
balance > 0
Line 2,731 ⟶ 2,782:
 
===caseOf:otherwise:===
 
<lang slate>c@(Net URLPathEncoder traits) convert
[ | byte1 byte2 byte3 digit1 digit2|
Line 2,751 ⟶ 2,801:
 
<lang slate>[p isAtEnd] whileFalse: [p next evaluate]].</lang>
 
=={{header|SIMPOL}}==
 
===if-else if-else===
 
<lang simpol>if x == 1
foo()
else if x == 2
bar()
else
foobar()
end if</lang>
 
===ternary if function===
 
<lang simpol>.if(x == 1, "hello", "world")</lang>
 
=={{header|Smalltalk}}==