let fold_left f x v = let r = ref x in for i = 0 to v.length - 1 do r := f !r (unsafe_get v i) done; !r