Native OCaml Rego/OPA policy engine
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-rego: array.flatten removes only one level of nesting

+4 -5
+4 -5
lib/eval.ml
··· 2682 2682 | "array.reverse", [ _ ] -> 2683 2683 raise (Eval_error "array.reverse: argument must be an array") 2684 2684 | "array.flatten", [ Value.Array xs ] -> 2685 - let rec flatten = function 2686 - | Value.Array ys -> List.concat_map flatten ys 2687 - | v -> [ v ] 2688 - in 2689 - Value.Array (List.concat_map flatten xs) 2685 + (* Single-level flatten: an outer array's elements are concatenated; 2686 + non-array elements pass through. *) 2687 + Value.Array 2688 + (List.concat_map (function Value.Array ys -> ys | v -> [ v ]) xs) 2690 2689 | "array.flatten", [ _ ] -> 2691 2690 raise (Eval_error "array.flatten: argument must be an array") 2692 2691 | "object.keys", [ Value.Object pairs ] ->