4 ms·
In the same vein, I'd love to see more articles about recursion that don't even mention, let alone demonstrate, solving factorials. There's gotta be something e
by MrVandemar 3y ago
In the same vein, I'd love to see more articles about recursion that don't even mention, let alone demonstrate, solving factorials. There's gotta be something else.
- mplanchard 3y agoTrees or graphs would be great! Or arbitrarily nested objects. Those things have probably represented 90% of the recursive functions I’ve actually written
- delta_p_delta_x 3y agoOr parsing. One of the most intuitive and elegant real-world uses of recursion. I've been writing an XML parser and everything is recursive. Of course, because XML is fundamentally a recursive data structure, a tree. Who in their right mind would sincerely reach for a recursion to solve factorials or Fibonacci first? Even the maths-minded people would write the sequence bottom-up, and stop when it reached their desired T(n); when programming it, they'd ask for a loop-esque construct that they could stop when a condition was reached.
- MrVandemar 3y agoTree's would be great, and an actual example would be threaded comments in a forum, or just nested lists.