Change listToInt function to tail recursive.