mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
Merge pull request #185 from actionshrimp/cclist-repeat-reversed
Don't reverse twice in `CCList.repeat`
This commit is contained in:
commit
9e51f8dc77
2 changed files with 7 additions and 2 deletions
|
|
@ -25,3 +25,4 @@
|
|||
- Fabian Hemmer (copy)
|
||||
- Maciej Woś (@lostman)
|
||||
- Orbifx (Stavros Polymenis)
|
||||
- Dave Aitken (@actionshrimp)
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue