diff --git a/core/CCKList.ml b/core/CCKList.ml index 897a9409..337310f4 100644 --- a/core/CCKList.ml +++ b/core/CCKList.ml @@ -32,6 +32,7 @@ type + 'a t = ] let nil = `Nil +let _nil () = nil let cons a b = `Cons (a,b) let empty = nil @@ -126,3 +127,17 @@ and _flat_map_app f l l' () = match l with | `Cons (x, tl) -> `Cons (x, _flat_map_app f (tl ()) l') +let flatten l = flat_map (fun x->x) l + +let range i j = + let rec aux i j () = + if i=j then cons i _nil + else if i to_list = [0;1;2;3;4;5] + range 0 0 |> to_list = [0] + range 5 2 |> to_list = [5;4;3;2] +*) diff --git a/core/CCKList.mli b/core/CCKList.mli index ac430092..0975a24c 100644 --- a/core/CCKList.mli +++ b/core/CCKList.mli @@ -71,3 +71,7 @@ val filter : ('a -> bool) -> 'a t -> 'a t val append : 'a t -> 'a t -> 'a t val flat_map : ('a -> 'b t) -> 'a t -> 'b t + +val flatten : 'a t t -> 'a t + +val range : int -> int -> int t