Haskell/Solutions/Next steps

Introducing pattern matching
The difference is what happens when the argument is smaller than. In both the second and the third versions, they will be matched only on the final cases (by the catch-all patterns  and , respectively). In the second version, the final case evaluates to  at once. In the third version, however, there is also the  guard, which is evidently true when the argument is less than  ; and thus the result will be. Thus,  for instance evaluates to   with the second version but to   with the third version.

N.B.: In a footnote to the text we claimed that for this example we wouldn't be too worried about what should happen if  was given nonsensical inputs; still, corner cases like this are the sort of issue that tends to trip us up when writing "real" code. In other words: it might make a difference in your program, so stay alert.

Here is a variation of the third version which is exactly equivalent to the second one: