Conditional structures: Difference between revisions
Content deleted Content added
Langurmonkey (talk | contribs) |
|||
(4 intermediate revisions by 3 users not shown) | |||
Line 2,493:
=={{header|EasyLang}}==
<syntaxhighlight>
i =
if i mod 2 = 0
print i & " is divisible by 2"
Line 2,501:
print i & " is not divisible by 2 or 3"
.
</syntaxhighlight>
=={{header|Ed}}==
Note that ed, unlike more advanced [[Sed]], has no conditional branching. Still, conditionals can be simulated with global match/no-match rules:
<syntaxhighlight>
g/True/s//It's true!/p
v/True/s/.*/It's false!/p
</syntaxhighlight>
Line 5,520 ⟶ 5,529:
PARI can use all of the usual [[Conditional structures/C|C conditionals]].
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
// if statement
if condition then
operator;
if condition then
operator
else operator;
if condition then
operator
else if condition then
operator
else operator;
// case statement
case Month of
3..5: Print('Spring');
6..8: Print('Summer');
9..11: Print('Autumn');
12,1,2: Print('Winter');
else throw ArgumentException('Bad Month')
end;
// ternary operator
var min := if a < b then a else b;
// ternary operator in C style
var min := a < b ? a : b;
</syntaxhighlight>
=={{header|Pascal}}==
Line 6,209 ⟶ 6,250:
"\s+" { "Line started with whitespace" }
}</syntaxhighlight>
=={{header|ProgressBASIC}}==
IF [CONDITION] THEN [ACTION]
ELSE {CONDITION2}
=={{header|Prolog}}==
|