-
Notifications
You must be signed in to change notification settings - Fork 227
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 flatten() #980
Add list flatten() #980
Conversation
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty neat, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to make this recursive by default? The common case is to flatten a list of list. I feel like a recursive flatten would better be a separate .flattenRec()
function.
@seirl I took inspiration from Elixir's List.flatten. However, I don't have a strong opinion and I am ok with what you proposed. |
Interesting. FWIW:
The reason I'm mentioning this is because |
@seirl Alright, I will change this to single-level flattening. |
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
/gcbrun |
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
/gcbrun |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the update. I've added a few comments on how to structure this so it's safer for production rollout and works with cost estimation tools!
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
/gcbrun |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update the signature of single-level flatten post-merge. Thanks for the contribution and the patience!
@TristonianJones, thank you for merging. I'm currently on vacation with limited laptop access. I'll handle the cost estimation if the task is still open when I return. Regarding the function signature, shouldn't it be something like |
@fabriziosestito the one-level .flatten() should only flatten List[List[T]], so [1, [2, 3]].flatten() should be an error. If you use only strongly-typed CEL, all your lists need to be homogeneous, so [1, [2, 3]] doesn't make sense as a value. |
@seirl I took care of the signature change in a different PR. The test case will pass checking because the mixed type list is |
Adds list flatten, fixing #352