mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-10 21:23:57 -05:00
Merge branch 'master' into master
This commit is contained in:
commit
77cd903134
2 changed files with 14 additions and 3 deletions
|
|
@ -25,4 +25,5 @@
|
||||||
- Fabian Hemmer (copy)
|
- Fabian Hemmer (copy)
|
||||||
- Maciej Woś (@lostman)
|
- Maciej Woś (@lostman)
|
||||||
- Orbifx (Stavros Polymenis)
|
- Orbifx (Stavros Polymenis)
|
||||||
- Rand (@rand00)
|
- Rand (@rand00)
|
||||||
|
- Dave Aitken (@actionshrimp)
|
||||||
|
|
|
||||||
|
|
@ -1253,11 +1253,21 @@ let replicate i x =
|
||||||
else aux (x::acc) (i-1)
|
else aux (x::acc) (i-1)
|
||||||
in aux [] i
|
in aux [] i
|
||||||
|
|
||||||
|
|
||||||
|
(*$T
|
||||||
|
repeat 2 [1;2;3] = [1;2;3;1;2;3]
|
||||||
|
*)
|
||||||
|
|
||||||
|
(*$Q
|
||||||
|
Q.(pair small_int (list int)) (fun (n,l) -> \
|
||||||
|
if n>0 then repeat n l = flat_map (fun _ -> l) (1--n) \
|
||||||
|
else Q.assume_fail())
|
||||||
|
*)
|
||||||
|
|
||||||
let repeat i l =
|
let repeat i l =
|
||||||
let l' = List.rev l in
|
|
||||||
let rec aux acc i =
|
let rec aux acc i =
|
||||||
if i = 0 then List.rev acc
|
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
|
in aux [] i
|
||||||
|
|
||||||
module Assoc = struct
|
module Assoc = struct
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue