[compile] use Array#reduce where appropriate