This repository was archived by the owner on Oct 4, 2020. It is now read-only.
Open
Conversation
probably nlogn
Contributor
|
I think this is good, but we should probably try to implement it by walking the tree, which would be more efficient. This is great for a first pass though, thanks! |
paf31
reviewed
Jun 3, 2017
| mapWithKey f (Three left k1 v1 mid k2 v2 right) = Three (mapWithKey f left) k1 (f k1 v1) (mapWithKey f mid) k2 (f k2 v2) (mapWithKey f right) | ||
|
|
||
| -- | Divide into two maps of keys less and greater than the provided argument. | ||
| split :: forall k v. Ord k => k -> Map k v -> { less :: Map k v, greater :: Map k v } |
Contributor
There was a problem hiding this comment.
Shouldn't the right be "greater or equal"? Maybe lt and ge would be good label names.
paf31
reviewed
Jun 3, 2017
| where | ||
| mapify {init: ls, rest: gs} = | ||
| {less: fromFoldable ls, | ||
| greater: fromFoldable $ LL.dropWhile (\(Tuple k' _) -> k' == k) gs} |
Contributor
There was a problem hiding this comment.
Or instead of dropping equal elements, why not add an eq key too?
Contributor
Author
There was a problem hiding this comment.
That makes good sense to me. Going to wait on it until I write a proper tree-traversing version, though, which should take us from nlogn to logn :)
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
addresses #26
Note that this probably has nlogn rather than logn performance, as in Haskell's collections. It can probably be improved very significantly. Would like to add some benchmarks (#101) before doing so.