logoalt Hacker News

Jaxanyesterday at 8:37 PM2 repliesview on HN

If I have to traverse a tree, then recursion is more natural to me. With a loop you’ll have to manually use a stack (it’s fine, but more error prone). For lists, I rarely write loops or recursion. It’s mostly folds and maps.


Replies

vnorilotoday at 5:46 AM

For sure. Data structures and call graphs like to converge, so when designing a data model, you are actually designing the (most natural) program flow too.

odyssey7yesterday at 9:01 PM

Linear recursion vs tree recursion.