question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Traversing infinite sequences

See original GitHub issue

From @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:closed
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
gustycommented, Feb 18, 2020

#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.

1reaction
gustycommented, Mar 5, 2017

Here you can get an idea of how the unified function would look like

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found