Re:Introducing Surinx (Ruby syntax w/ Java typing)
by gloob on Wednesday August 26, 2009 @01:30PM
(#787627)
Whether it does tail call optimization is a different question than whether you can write the algorithm in a tail-recursive manner, though.
[ Parent
| on HN ]
Re:Introducing Surinx (Ruby syntax w/ Java typing)
by steveklabnik on Wednesday August 26, 2009 @01:33PM
(#787637)
Yes, but without the optimization, how would it help? Am I just being a n00b?
Re:Introducing Surinx (Ruby syntax w/ Java typing)
by mbrubeck on Wednesday August 26, 2009 @02:24PM
(#787745)
Writing it tail-recursively forces you to switch from the O(2^n) algorithm (which has two recursive calls; you can't put both into tail position) to a more efficient algorithm. You could also write the more-efficient algorithm without tail recursion, of course.
Re:Introducing Surinx (Ruby syntax w/ Java typing)
by apgwoz on Wednesday August 26, 2009 @02:19PM
(#787735)
No, you're not being a n00b. It'll help because the stack usage will grow linearly as opposed to quadratically, as in the case of the naive solution. You'll still overflow the stack without the optimization.