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