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

[transducers] Add transjuxt #408

Open
rostero1 opened this issue Aug 23, 2023 Discussed in #407 · 0 comments
Open

[transducers] Add transjuxt #408

rostero1 opened this issue Aug 23, 2023 Discussed in #407 · 0 comments

Comments

@rostero1
Copy link

Add support for transjuxt that'd behave similar to:

(def data [{:name "pete" :supply 1}
           {:name "pete" :supply 2}
           {:name "john" :supply 2}
           {:name "sara" :supply 1}
           {:name "jane" :supply 2}
           {:name "sara" :supply 2}])

(x/transjuxt [(comp (map :name) (distinct) (x/sort) (x/into []))
              (comp (map :supply) (distinct) (x/sort) (x/into []))]
             data)

Discussed in #407

Originally posted by rostero1 August 19, 2023
I have a dataset:

type Data = { id: number; name: string; supply: number };
type Results = Data[];

How can I write a transducer that will give me{ uniqNames: string[], uniqSupply: number[] }, where names are all the uniq names and unique supply. I also need each result sorted both ascending.

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