let init length f = let result = ref [] in for i=length-1 downto 0 do result := f i :: !result done; !result