Allow compareLength to shortcircuit in both directions #76
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a more invasive alternative to the patch I offered up in #75.
This permits early termination in many inexact cases (like, you know,
stream
!) by tracking both minimum as well as maximum sizes.This means that examples like
can both execute in O(1), spite the fact that
stream
has to give an inexact bound on its size. This is because it can give both an upper bound (as usual) and lower bound (words / 2) for use in the test.In theory more combinators could be extended to make use of the lower bounds.
I tried to exhibit care to preserve sharing like the original code, but this version could definitely use a pair of eyeballs.
If it is too much trouble then by all means just take the other version. =)