expr-lang / expr

Expression language and expression evaluation for Go
https://expr-lang.org
MIT License
5.85k stars 378 forks source link

Add `flatten()` builtin #672

Open antonmedv opened 3 weeks ago

antonmedv commented 3 weeks ago

Add flatten builtin.

flatten([["a", "b"], [1, 2]]) == ["a", "b", 1, 2]
OlgaNovg commented 2 weeks ago

flatten([["a", "b"], [1, 2, [3, 4]]]) == ["a", "b", 1, 2, 3, 4] or ["a", "b", 1, 2, [3, 4]] ?

antonmedv commented 2 weeks ago

["a", "b", 1, 2, 3, 4] Lets make it to all nested arrays.

vmihailenco commented 1 day ago

Would be nice if the function also supports maps, e.g. just like VRL https://vector.dev/docs/reference/vrl/functions/#flatten