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

Add built-ins for common array operations #851

Closed
tsandall opened this issue Jul 26, 2018 · 0 comments
Closed

Add built-ins for common array operations #851

tsandall opened this issue Jul 26, 2018 · 0 comments

Comments

@tsandall
Copy link
Member

There are a handful of operations on arrays that are not well-supported today. While you can define arrays statically and generate them dynamically with comprehensions, it becomes difficult to perform certain operations like concatenating and slicing. The workarounds for these operations are overly complex and perform poorly.

We should add the following set of built-ins to operate on arrays:

slice([1,2,3,4], 1, 3) = [2,3]
concat([1,2,3], [4,5]) = [1,2,3,4,5]

Note that concat is already used for string concatenation. If we want to use the same name we need to add support for overloading in the type checker.

tsandall added a commit to tsandall/opa that referenced this issue Aug 6, 2018
Fixes open-policy-agent#851

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
tsandall added a commit that referenced this issue Aug 6, 2018
Fixes #851

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
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