I do not use recursive often, like really not that much.
The only time I used it is when I found myself creating this old NodeJS package to "inline" codes imported in a file (using ES6 import syntax" down to the main file).
In this case, I needed to get an AST of the file, and, whenever I encountered an import "foo", I would get the AST of this file, and in this sub file, whenever I encountered an import "bar", I would get the AST of this file, and...
You got the idea 😂
So I guess recursivity made sense in this case because this was natural to think of a fractal way to solve this.
Else, I would do some sequential algorithm to solve my problems, which would eventually requires iterating.
I'd definitely agree with you on that: it all depends upon the requirement for which one's more appropriate for that specific use-case. For me, in most cases, I get the hint within seconds of looking at the problem.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I do not use recursive often, like really not that much.
The only time I used it is when I found myself creating this old NodeJS package to "inline" codes imported in a file (using ES6 import syntax" down to the main file).
In this case, I needed to get an AST of the file, and, whenever I encountered an
import "foo"
, I would get the AST of this file, and in this sub file, whenever I encountered animport "bar"
, I would get the AST of this file, and...You got the idea 😂
So I guess recursivity made sense in this case because this was natural to think of a fractal way to solve this.
Else, I would do some sequential algorithm to solve my problems, which would eventually requires iterating.
I'd definitely agree with you on that: it all depends upon the requirement for which one's more appropriate for that specific use-case. For me, in most cases, I get the hint within seconds of looking at the problem.