Undefined values: Difference between revisions
Content added Content deleted
Underscore (talk | contribs) (Added Haskell.) |
Underscore (talk | contribs) m (→{{header|Haskell}}: "1/0" -> "1 `div` 0") |
||
Line 8: | Line 8: | ||
This isn't quite as dangerous as it sounds because of Haskell's laziness. For example, this program: |
This isn't quite as dangerous as it sounds because of Haskell's laziness. For example, this program: |
||
<lang haskell>main = print $ length [undefined, undefined, 1 |
<lang haskell>main = print $ length [undefined, undefined, 1 `div` 0]</lang> |
||
prints <code>3</code>, since <code>length</code> doesn't need to evaluate any of the elements of its input. |
prints <code>3</code>, since <code>length</code> doesn't need to evaluate any of the elements of its input. |