Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在 jsonnet 中添加数组的元素。有人可以发布样本吗?
样本输入:[0, 1, 2, 3]
[0, 1, 2, 3]
输出 6
6
您可以使用std.foldl()作为“聚合”函数:
local myArray = [0, 1, 2, 3]; std.foldl(function(x, y) (x + y), myArray, 0)