Don't reverse twice in CCList.repeat

This commit is contained in:
Dave Aitken 2018-02-04 17:34:30 +00:00
parent 04d10c2711
commit 710266e09c

View file

@ -1253,11 +1253,15 @@ let replicate i x =
else aux (x::acc) (i-1)
in aux [] i
(*$T
repeat 2 [1;2;3] = [1;2;3;1;2;3]
*)
let repeat i l =
let l' = List.rev l in
let rec aux acc i =
if i = 0 then List.rev acc
else aux (List.rev_append l' acc) (i-1)
else aux (List.rev_append l acc) (i-1)
in aux [] i
module Assoc = struct