Conditional structures: Difference between revisions

no edit summary
(Jakt)
No edit summary
Line 2,570:
x::xs = x :: force xs
[] = []</syntaxhighlight>
 
 
=={{header|EMal}}==
<syntaxhighlight lang="emal">
int i = 19
^|if–then–else|^
if i > 18
writeLine("greater than 18")
else
writeLine("less or equal to 18")
end
^|else if|^
if i == 18 do writeLine("equal to 18")
else if i < 18 do writeLine("less than 18")
else do writeLine("greater than 18")
end
^|when expression: just like iif in Visual Basic|^
writeLine(when(i > 18, "greater than 18", "less or equal to 18"))
^|hash-based conditionals|^
Map dispatch = int%fun[
18 => <|writeLine("equal to 18"),
19 => <|writeLine("yeah, it's 19")]
if dispatch.has(i) do dispatch[i]() end
</syntaxhighlight>
{{out}}
<pre>
greater than 18
greater than 18
greater than 18
yeah, it's 19
</pre>
 
=={{header|Erlang}}==
222

edits