chunkBy
Split a flat sequence into chunks. A new chunk starts whenever the predicate returns true.
array(required): the array to splitpredicate(required): lambda(element) -> boolean— true starts a new chunk
bash
echo '{"items": [1, 2, 10, 11, 12, 20, 21]}' \
| utlx -e 'chunkBy($input.items, (x) -> x >= 10 and x % 10 == 0)'
# [[1, 2], [10, 11, 12], [20, 21]]utlx
// See Chapter 20 for data restructuring patterns.
{
groups: chunkBy($input.records, (r) -> r.isHeader)
}