Conditional structures: Difference between revisions

no edit summary
m (→‎when: oops; forgot a tag)
No edit summary
Line 753:
show_switch_with_parenthesis(random.uniform(3))
show_switch_without_parenthesis(random.uniform(3))
}</lang>
}
 
=={{header|Ela}}==
 
===if-then-else===
 
<lang ela>if x < 0 then 0 else x</lang>
 
===Guards===
 
<lang ela>let getX x | x < 0 = 0
| else = x</lang>
 
===Pattern matching===
 
<lang ela>let force (x::xs) = x :: force xs
force [] = []</lang>
 
===match expression===
 
<lang ela>
let force lst = match lst with
x::xs = x :: force xs
[] = []</lang>
 
===is expression===
 
<lang ela>
let force lst = if lst is (x::xs) then
x :: force xs
else []</lang>
 
</lang>
 
=={{header|Factor}}==
Anonymous user