def accumulates(f): foreach .[] as $row (0; . + ($row | f) ; . as $x | $row | (f = $x)); accumulates(.nbrMembers)