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

Incorporate newly-added lambda and object functions #13605

Closed
anthony-c-martin opened this issue Mar 13, 2024 · 4 comments
Closed

Incorporate newly-added lambda and object functions #13605

anthony-c-martin opened this issue Mar 13, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request new function
Milestone

Comments

@anthony-c-martin
Copy link
Member

anthony-c-martin commented Mar 13, 2024

The following functions and changes to existing functions were added in ARM's 2024w12 release:

New functions:
objectKeys: Returns the keys of an object parameter.
mapValues: Create an object from an input object, using a custom lambda to map values.
groupBy: Create an object with array values from an array, using a grouping condition.
shallowMerge: Perform a shallow merge of input object parameters. Required to implement a "spread" operator in Bicep.

Updated functions:
map: Support optional index argument.
reduce: Support optional index argument.
filter: Support optional index argument.

Once this release has been rolled out globally, we should update Bicep to support the new capabilities.

This addresses some of the issues described under the following: #9244, #1560, #2082, #1853

@miqm
Copy link
Collaborator

miqm commented Apr 12, 2024

@anthony-c-martin will the distinct function also be available?

@anthony-c-martin
Copy link
Member Author

@anthony-c-martin will the distinct function also be available?

No, sorry - this wasn't one of the functions I added. For distinct, what behavior would you expect for handling arrays and objects?

My expectation would be exact structural equality:

var a = distinct([[1], [1]) // returns [[1]]
var b = distinct([[1, 2], [1]) // returns [[1, 2], [1]]
var c = distinct([{a: 1}, {a: 1}] // returns [{a: 1}]
var d = distinct([{a: 1}, {a: 1, b: 2}]) // returns [{a: 1}, {a: 1, b: 2}]

It may also be useful to add a distinctBy function that accepts a lambda:

var foo = distinctBy([{a: 1}, {a: 1, b: 2}], (x, y) => x['a'] == y['a']) // returns [{a: 1}]

@anthony-c-martin
Copy link
Member Author

Closed by #13658.

@miqm for the distinct ask - please could you raise a new issue and answer my above question?

@github-project-automation github-project-automation bot moved this from Todo to Done in Bicep Apr 24, 2024
@miqm
Copy link
Collaborator

miqm commented Apr 24, 2024

Closed by #13658.

@miqm for the distinct ask - please could you raise a new issue and answer my above question?

#2082 already exists. It was mentioned in the ticket description therefore I asked if it's going to be supported as I didn't see it on the list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new function
Projects
Archived in project
Development

No branches or pull requests

3 participants