On Thu, May 14, 2009 at 12:48 PM, Roger Hui <[email protected]> wrote:
> The question really is, can you code it recursively > without paying severe performance penalty? > (Why else would you avoid recursion if a recursive > solution is shorter, simpler, more robust, etc.) > > Answer: yes. > > fib=: 3 : 0 M. > if. 2>y do. y else. (fib y-1) + (fib y-2) end. > ) > > fib1=: 3 : 0 > if. 2>y do. y else. (fib1 y-1) + (fib1 y-2) end. > ) > BTW, TCO would not help in this case even it is implemented. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
