My first time doing recursion was implementing an indentation level calculation for showing threaded/nested child comments in a mailing list display UI, one of my first web apps. The mysql table I had populated had an id and a parent and I just repeatedly queried the db for any objects that had the current item as parent, depth-first.
I didn’t realize that it was a threshold moment, and I didn’t even know if it was syntactically legal or allowed for a function to call itself (I had no formal CS training) but I remember struggling with the “how much should these child elements be indented” problem and eventually trying it and it worked; it was quite a rush for 14-year-old me.
Maybe try implementing something simple and straightforward that uses it, like a web front end that displays a directed graph of nested comments/message replies?
Comments
My first time doing recursion was implementing an indentation level calculation for showing threaded/nested child comments in a mailing list display UI, one of my first web apps. The mysql table I had populated had an id and a parent and I just repeatedly queried the db for any objects that had the current item as parent, depth-first.
I didn’t realize that it was a threshold moment, and I didn’t even know if it was syntactically legal or allowed for a function to call itself (I had no formal CS training) but I remember struggling with the “how much should these child elements be indented” problem and eventually trying it and it worked; it was quite a rush for 14-year-old me.
Maybe try implementing something simple and straightforward that uses it, like a web front end that displays a directed graph of nested comments/message replies?