There's no (practical) advantage to the circular implementation; it's just a curiosity.
It is useful for understanding laziness and some interesting theoretical tools for traversing data structures, though. For a more in-depth look at the idea of circular programs for traversal, Bird's paper (linked in the post, https://link.springer.com/article/10.1007/BF00264249) is a good start.
2 comments
[ 3.0 ms ] story [ 18.1 ms ] threadIs it faster than the simple one? Does it use less memory? Is it easier to write? Is it easier to understand?
I think all of the above is false, but I have a limited understanding of Haskell. Please correct me if I'm wrong.
It is useful for understanding laziness and some interesting theoretical tools for traversing data structures, though. For a more in-depth look at the idea of circular programs for traversal, Bird's paper (linked in the post, https://link.springer.com/article/10.1007/BF00264249) is a good start.