Azure / Azure/bicep

Addition of some missing "set theory" array functions.

Open
#9,953 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

Today I had to do some array juggling and was looking for Bicep functions to assist me. I found the `concat`, `intersection` and `union` functions particularly helpful. However, some "set theory" functions seemed notably absent.

In particular I was looking for a difference/complement/except function `except(A, B)`, that would return all elements present in array `A`, but not in array `B`. Like this:
```
param firstArray array = [
'one'
'two'
'three'
'four'
]

param secondArray array = [
'three'
'four'
'five'
]

output arrayOutput array = except(firstArray, secondArray)
```
The output would be:
Name | Type | Value
-- | -- | --
arrayOutput | Array | ["one", "two"]

Another would be the symmetric difference/disjunctive union of arrays, `symmetricExcept(A, B)`, that would return all elements present in array `A` and array `B`, but not in both. Like this:
```
param firstArray array = [
'one'
'two'
'three'
'four'
]

param secondArray array = [
'three'
'four'
'five'
]

output arrayOutput array = symmetricExcept(firstArray, secondArray)
```
The output would be:
Name | Type | Value
-- | -- | --
arrayOutput | Array | ["one", "two", "five"]

Of course there are more "set theory" functions (carthesian product comes to mind) missing. And maybe these proposed functions can be realized using some alternative Bicep code/lambda expressions. It sure would've helped me today if these functions were already available in Bicep, so I thought I'd add this feature suggestion. My sample is based on arrays, but just like some of the already existing functions, I imagine they should also be available for objects.

Contributor guide

Open the contributing guide

Research direction

The issue names no files, tests, or entry points. Start by locating the existing concat, intersection, and union array functions, then determine the intended scope and semantics for additional set operations on arrays and objects; done means the supported operations and their behavior are implemented and tested.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.