Here is a repeat
function that recursively calls itself
const repeat = x => f => {
if (x > 0) {
f()
return repeat (x - 1) (f)
}
}
The problem with it is it can cause stack overflow. I was wondering if I can rewrite it using tail call recursion so it can be stack-safe.