diff --git a/AUTHORS.adoc b/AUTHORS.adoc index 0d996399..56dba742 100644 --- a/AUTHORS.adoc +++ b/AUTHORS.adoc @@ -25,4 +25,5 @@ - Fabian Hemmer (copy) - Maciej Woś (@lostman) - Orbifx (Stavros Polymenis) -- Rand (@rand00) \ No newline at end of file +- Rand (@rand00) +- Dave Aitken (@actionshrimp) diff --git a/src/core/CCList.ml b/src/core/CCList.ml index 3da6407f..20e9c77d 100644 --- a/src/core/CCList.ml +++ b/src/core/CCList.ml @@ -1253,11 +1253,21 @@ 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] +*) + +(*$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 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