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 List.partitionMap #149

Open
Dean177 opened this issue Jun 18, 2020 · 0 comments
Open

Add List.partitionMap #149

Dean177 opened this issue Jun 18, 2020 · 0 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed in-dark-repo There's an implementation which can be copied from https://github.com/darklang/dark

Comments

@Dean177
Copy link
Collaborator

Dean177 commented Jun 18, 2020

 (* Partition into two lists, of potentially different type, using function
   * `f`.  Returns value in the first list for `Left` and second list for
   * `Right`. *)
  let partitionMap (items : 'c list) ~(f : 'c -> ('a, 'b) Either.t): ('a list * 'b list) =
    TableclothList.foldRight
      ~initial:([], [])
      ~f:(fun (lefts, rights) item ->
        match f item with
        | Left a ->
            (a :: lefts, rights)
        | Right b ->
            (lefts, b :: rights))
      items
@Dean177 Dean177 added help wanted Extra attention is needed good first issue Good for newcomers labels Jun 18, 2020
@pbiggar pbiggar added the in-dark-repo There's an implementation which can be copied from https://github.com/darklang/dark label Aug 2, 2021
@pbiggar pbiggar added this to the 0.2.0 milestone Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed in-dark-repo There's an implementation which can be copied from https://github.com/darklang/dark
Projects
None yet
Development

No branches or pull requests

2 participants