Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Admittedly recursion is not done often, but in some cases it's very useful. For example, recently I created an application with a tree record structure where the user could delete a node and it needed to delete all sub-nodes. With recursion it's easy to tell: 'call yourself for all subnodes you have, then delete yourself'. This is something that's much more difficult to express with the usual for/while constructs.

Example: https://github.com/skriticos/tac_workflow/blob/9890e66d60851...



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: