News for hackers. Stuff that matters.
Re:PyTorch: Where we are headed and why it looks a lot like ... by Vetch on Saturday November 27, 2021 @10:02AM (#29360649)
I can't think of a specific example but I do know that there have been times where I have chosen to write a loop as tail recursion and times where I have used mutable variables and a while loop. Why one or the other might be recursion better capturing intent, preferring immutability, efficiency or just a matter of taste.

Sometimes it makes more sense and is more flexible to package functionality as a recursive function, then mutation and variables feel like clutter. Other sometimes using recursion instead of a loop gains nothing expressively. Or sometimes structural recursion + pattern matching is the much more elegant approach in terms of communicating and capturing the essence of the algorithm.

There are no comments on this comment yet.