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

Flatten or reduce a list of lists #352

Closed
2 of 3 tasks
btomasini opened this issue May 11, 2020 · 4 comments
Closed
2 of 3 tasks

Flatten or reduce a list of lists #352

btomasini opened this issue May 11, 2020 · 4 comments

Comments

@btomasini
Copy link

btomasini commented May 11, 2020

Feature request checklist

  • There are no issues that match the desired change
  • The change is large enough it can't be addressed with a simple Pull Request
  • If this is a bug, please file a Bug Report.

Change
I don't know if this is a feature request or a request for assistance. I have a cel expression which maps a list and in the predicate does a lookup against a map<string, list>. The result is a list of lists of stings, eg [['a'],[],['b', 'c']]. I would like to combine these into a single list of ['a','b','c']. Here are some options I have thought of:

  1. A flatmap macro.
  2. A flatten function
  3. A reducer in which I append the lists together

So far I am closest to implementing option 2 but am having some troubles with the InstanceOverloads not matching the input type.

Are there any built-in features of cel-go which would support this?

I am closest to implementing option 2 on my own but am having some troubles with the instance overloads not matching. If there is no built-in feature of cel-go for this, I will post a code sample here of my current work.

@TristonianJones
Copy link
Collaborator

Hi @btomasini. A function makes the most sense (Option 2). Do you happen to have an example, test case, or gist that you could share?

@btomasini
Copy link
Author

@TristonianJones

My original attempt failed as I treated it as an instance override rather than a global. I plan to try again soon and will let you know what I come up with it.

@TristonianJones
Copy link
Collaborator

@btomasini If you'd like some general support for CEL, you're also welcome to reach out to [email protected]. It's usually a better forum for free-form discussion.

@TristonianJones
Copy link
Collaborator

Hi @btomasini if you need any further help, I'd be happy to help in the discussion forums. For now, I'm closing the issue.

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

2 participants