News for hackers. Stuff that matters.
Re:Understanding Recursion as an Absolute Beginner by rileytg on Thursday September 05, 2019 @03:37PM (#20890026)
not necessarily efficient but here’s my latest use case:

scheduling a health check job recursively. if the health check fails, it schedules itself to run again in X seconds with N-1 runs until giving up and marking the service as down.

iteration here simply wouldn’t work

Re:Understanding Recursion as an Absolute Beginner by bananasbandanas on Friday September 06, 2019 @07:01AM (#20894560)
Why not?

Just schedule a single health check with a loop that tries to health-check N times in a loop, with a delay in between. If the check succeeds at any point, return 'healthy' early.

Or schedule N health checks at different times, if any check succeeds cancel all others, etc. etc.