Not tail recursive

May 12th, 2007 / Development in a Blink

PowerShell supports recursion but not tail recursion. A simple test. function simpleTest ($n) {     if($n -ne 0) { $n; simpleTest ($n-1) } } PS C:> simpleTest 10 10 9 8 7 6 5 4 3 2 1 PS C:> simpletest 99 99 98 97 96 95 The script failed due to call depth overflow. The call depth reached 101 and the maximum is 100. Bruce Payette, co-designer of PowerShell, responds Recursion depth limit is fixed in version 1. [...]

Comments are closed.