-
Notifications
You must be signed in to change notification settings - Fork 253
Fixed bug in FingerTree.append(). Added PropertyTestRunner #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3845b21
Fixed bug in FingerTree.append(). Added PropertyTestRunner, SeqProper…
orionll 69b3865
Fixed bugs in standard random generator, Gen.listOf(). Added Arbitrar…
orionll c2a126a
Added NonEmptyList.hashCode(), Hash.bigintHash, Hash.bigdecimalHash
orionll 74103b4
Added methods for NonEmptyList: snoc(), reverse(), intersperse(), sor…
orionll 9305748
Added JavaDoc for new NonEmptyList methods.
orionll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,38 +124,15 @@ public Random f(final Long x) { | |
| /** | ||
| * A standard random generator that uses {@link Random}. | ||
| */ | ||
| public static final Rand standard = new Rand(new F<Option<Long>, F<Integer, F<Integer, Integer>>>() { | ||
| public F<Integer, F<Integer, Integer>> f(final Option<Long> seed) { | ||
| return new F<Integer, F<Integer, Integer>>() { | ||
| public F<Integer, Integer> f(final Integer from) { | ||
| return new F<Integer, Integer>() { | ||
| public Integer f(final Integer to) { | ||
| if(from == to){ | ||
| return from; | ||
| }else{ | ||
| final int f = min(from, to); | ||
| final int t = max(from, to); | ||
| final int x = Math.abs(t - f); | ||
| return f + seed.map(fr).orSome(new Random()).nextInt(x == Integer.MIN_VALUE ? Integer.MAX_VALUE : x); | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| }; | ||
| } | ||
| }, new F<Option<Long>, F<Double, F<Double, Double>>>() { | ||
| public F<Double, F<Double, Double>> f(final Option<Long> seed) { | ||
| return new F<Double, F<Double, Double>>() { | ||
| public F<Double, Double> f(final Double from) { | ||
| return new F<Double, Double>() { | ||
| public Double f(final Double to) { | ||
| final double f = min(from, to); | ||
| final double t = max(from, to); | ||
| return seed.map(fr).orSome(new Random()).nextDouble() * (t - f) + f; | ||
| } | ||
| }; | ||
| } | ||
| }; | ||
| } | ||
| public static final Rand standard = new Rand(seed -> from -> to -> { | ||
| final int min = min(from, to); | ||
| final int max = max(from, to); | ||
| final Random random = seed.map(fr).orSome(new Random()); | ||
| return (int) ((random.nextLong() & Long.MAX_VALUE) % (1L + max - min)) + min; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me explain why I changed these lines. There were two bugs here:
|
||
| }, seed -> from -> to -> { | ||
| final double min = min(from, to); | ||
| final double max = max(from, to); | ||
| final Random random = seed.map(fr).orSome(new Random()); | ||
| return random.nextDouble() * (max - min) + min; | ||
| }); | ||
| } | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this always a list of size 1, rather than some arbitrary length?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
[0, ∞)).[1, ∞)).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, but I had to dig through the code to convince myself this is true. The existing javadoc should be more specific.