Hi, I’ve been working in some challenges and I’ve found that due to the features of some challenges I can’t avoid get stack overflow, if I use a functional programming approach.
What do you understand or find about that problem
I got this problem with two different challenges, the problem appear when I need to generate a big amount of data, for example in this challenge: https://www.codeabbey.com/index/task_view/most-frequent-word is necessary generate 900,000 * 6 randoms values, if I use recursion in my function for the random generator, this is not only quite inefficient, but also I got stack overflow before that I can generate the first 9,000 data.
You make any workaround? What did you do?
I tried to program something like a “nested while” using two recursive function, with the objective to limit the depth that each recursive function could reach, but as it was expected, this is not only even more inefficient but also broke my virtual machine every run time , after that I decided to move to an OOP approach and I found that I can make the work in less than one second.
I need help with
I want to know if in this kind of cases when recursion go so deep, is possible to use OOP approach instead of FP, if this not possible I’d want to know if there are some approach that might help to overcome this problem . Thx!!