Possible Duplicate:
Combine memoization and tail-recursion
So the following is the code that I wrote, tail call optimized using an accumulation variable
let rec counter init count =
if init = 1 then count + 1 else
match init with
| Even value -> (counter (value/2) (1 + count))
| Odd value -> (counter ((3 * value) + 1) (count+1))
let SeqBuilder (initval:int) : int = counter initval 0
How do I memoize this? the problem I ran into when I tried to memoize it is that the recursive call has to go to the memoize object, so you have to have a...recursive object?
Or is it a lot simpler and I am just inexperienced?