4 ms·
That's just a combination of pattern matching and tail call optimization. That code would look exactly this same in Haskell: countToTen n = countToTen (n +
by fbonetti 9y ago
That's just a combination of pattern matching and tail call optimization. That code would look exactly this same in Haskell:
countToTen n = countToTen (n + 1)
countToTen 10 = done
- dllthomas 9y agoThe 10 case would have to be first, or that's an infinite loop. Cases are checked in order. That said, the compiler will give you a warning about it.