Skip to content
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

Add deleteSubmap #10

Closed
wants to merge 2 commits into from
Closed

Conversation

QuietJoon
Copy link

@QuietJoon QuietJoon commented May 12, 2020

Could you add this new function?

I've been used bytestring-trie for many use case, and I implement a function for myself like

deleteSubmap' key trie =
    foldr
        (\k t -> delete k t)
        trie
        (keys $ submap key trie)

However, because it traverses every deleting target entries, this version is too slow.

Could you add my implementation in the Data.Trie.Internal?

I'm not sure that the function's name and actual implementation is proper for your package.
If you care, please rename&change it.

@wrengr
Copy link
Owner

wrengr commented Nov 20, 2021

You can actually already get this efficiently via:

deleteSubmap q = alterBy_ (\_ _ _ _ -> (Nothing, empty)) q undefined

Granted the need for the undefined value there is a bit unsightly. I can adjust the type of alterBy_ to avoid that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants