I come from a functional programming background and think first about recursive solutions to problems rather than iterative ones. I'm starting to work with Rebol a bit (specifically R3) and have written a solution to the primefactor kata using a tail-recursive function with an accumulator. But with any sufficiently large input I blow the stack. I have a script for Rebol2 called "tail-func.r" which implements a version of tail-call optimization that AFAIK has not been ported to R3. I know that Rebol 3 implements things differently than R2 in many cases, so is there a way to get TCO in Rebol 3 without any extra code? If not, is there a simpler way to get it without porting the old script?
Edited to add my code:
primefactors: function [n m factors] [
either n > 1
[ either (modulo n m) == 0
[ primefactors (n / m) m (append factors m) ]
[ primefactors n (m + 1) factors ] ]
[ factors ]
]
primefactors 30 2 (copy []) => [2 3 5]