F# continuation-based tail recursion

Viewed 1512

Can someone clarify the need for acc "" when terminating a continuation-based tail-recursive function like in the following example:

let rec repeat_cont i s acc = 
if i = 0 then acc ""
else repeat_cont (i-1) s (fun x -> acc(s + x))

repeat_cont 4 "xo" id
val it : string = "abababab"

If the result is a list, it'd be acc [], and acc 0 for integer.

3 Answers
Related