Traversing infinite sequences
See original GitHub issueFrom @mausch on April 16, 2014 21:23
Traversing an infinite list works fine in Haskell: http://ideone.com/GuytMd But the equivalent F# + FSharpPlus code doesn’t terminate and eats infinite memory:
let x = traverse (fun x -> if x > 4 then Some x else None) (Seq.initInfinite id)
This is probably because foldr is currently strict for seq
Maybe a specialized foldr would work here, e.g. http://fpish.net/blog/anton.tayanovskyy/id/1453/http~3a~2f~2fwww.intellifactory.com~2fblogs~2fanton.tayanovskyy~2f2009~2f12~2f11~2fFoldr-or-FoldBack-on-Infinite-F~21sharp~21-Sequences.article
(BTW this stackoverflow question made me realize this).
Copied from original issue: gmpl/FsControl#26
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Traversing the Infinite
To say an infinite series converges to a finite sum simply says that it approaches a finite sum. (Of course the infinite series,...
Read more >Traversing an Infinite?
God created the universe a finite time ago, but there's a question of whether we can prove this by reason alone.
Read more >Moreland on the Impossibility of Traversing the Infinite
Abstract: A key premise of the kalam cosmological argument is that the universe began to exist. However, while a number of philosophers have...
Read more >Alanyzer: On Traversing an Actually Infinite Past
If every traversal requires a beginning and an end, and an infinite past has no beginning, this is a problem only if we...
Read more >Traversing the Infinite
A very interesting discussion of whether the infinite can be traversed is going on at Philosophy, etc. I'm inclined to agree with some...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
#268 solves this issue in a generic way
It requires to have available a predicate (as part of the applicative abstractions) which tells whether an element is the cancelling element for the operation, called left-zero.
Here you can get an idea of how the unified function would look like