Why foldRight and reduceRight are NOT tail recursive?
问题 Why compiler does not translate Scala (1,2,3,4,5,6).foldRight(10)(_ * _) to Java equivalent final int[] intArray = new int[]{1,2,3,4,5,6}; int accumulator = 10; for(int i = intArray.legth - 1; i >=0; i--) { accumulator = intArray[i] * accumulator; } The question is: Why foldLeft and reduceLeft are tail recursive, but their right counteparts aren't? Here are links which says that right handed aren't tail recursive. I am asking why it is so. How do you know when to use fold-left and when to use