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

Dict/Set.fold*ByOrder proposal #1109

Open
pravdomil opened this issue May 10, 2021 · 1 comment
Open

Dict/Set.fold*ByOrder proposal #1109

pravdomil opened this issue May 10, 2021 · 1 comment

Comments

@pravdomil
Copy link

pravdomil commented May 10, 2021

Hi, I was searching for function that gets things from Dict/Set by prefix (for indexing purposes).
So I found that fold*WithOrder function would be quite handy.

foldlByOrder : (k -> Order) -> (k -> v -> a -> a) -> a -> Dict k v -> a
foldlByOrder toOrder fn acc a =
    case a of
        RBEmpty_elm_builtin ->
            acc

        RBNode_elm_builtin _ k v left right ->
            case toOrder k of
                LT ->
                    foldlByOrder toOrder fn acc left

                EQ ->
                    foldlByOrder toOrder fn (fn k v (foldlByOrder toOrder fn acc left)) right

                GT ->
                    foldlByOrder toOrder fn acc right
@github-actions
Copy link

Thanks for reporting this! To set expectations:

  • Issues are reviewed in batches, so it can take some time to get a response.
  • Ask questions a community forum. You will get an answer quicker that way!
  • If you experience something similar, open a new issue. We like duplicates.

Finally, please be patient with the core team. They are trying their best with limited resources.

@pravdomil pravdomil changed the title Dict/Set.getByOrder proposal Dict/Set.foldrWithOrder proposal Jun 14, 2021
@pravdomil pravdomil changed the title Dict/Set.foldrWithOrder proposal Dict/Set.foldl/rWithOrder proposal Jun 14, 2021
@pravdomil pravdomil changed the title Dict/Set.foldl/rWithOrder proposal Dict/Set.fold*WithOrder proposal Jun 14, 2021
@pravdomil pravdomil changed the title Dict/Set.fold*WithOrder proposal Dict/Set.fold*ByOrder proposal Aug 17, 2022
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

No branches or pull requests

1 participant