1

If I have two arrays, for example,

local array1 = [0,6,12];
local array2 = std.range(10,15);

and I want an array [0,6,10,11,12,13,14,15] (not concerned specifically about ordering of the elements, just don't want duplicates)

How can I perform this as a union operation that will work for any two arrays of numbers?

JustinJDavies
  • 2,663
  • 4
  • 30
  • 52

1 Answers1

2

JSonnet has the function std.setUnion for this use-case. Your result can be found with:

local result = std.setUnion(array1, array2);

See the JSonnet Standard Library reference for more details.

Jon Davies
  • 487
  • 4
  • 11