Detect division by zero: Difference between revisions

added langur language example
m (syntax highlighting fixup automation)
(added langur language example)
Line 1,306:
 
If the division node receives zero on both nodes (0/0), the Result will be "NaN"
 
=={{header|langur}}==
<syntaxhighlight lang="langur">val .div = f(.x, .y) {
[.x / .y, true]
catch {
if matching(re/division by 0/, _err["msg"]) {
[0, false]
} else {
# rethrow the error if not division by 0
throw
}
}
}
 
writeln .div(3, 2)
writeln .div(3, 0)
</syntaxhighlight>
 
{{out}}
<pre>[1.5, true]
[0, false]
</pre>
 
=={{header|Lasso}}==
890

edits