From: Richard W.M. Jones <"Richard W.M. Jones "> Date: Tue, 15 Apr 2008 21:31:08 +0000 (+0100) Subject: Added range library function. X-Git-Tag: 1.0.4~24^2~13 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=b06f8da33e1e87a64ec785e248e47e47fee9073f;p=virt-top.git Added range library function. --- diff --git a/virt-df/virt_df.ml b/virt-df/virt_df.ml index f8f34ab..63bb090 100644 --- a/virt-df/virt_df.ml +++ b/virt-df/virt_df.ml @@ -258,3 +258,7 @@ let group_by ?(cmp = Pervasives.compare) ls = in let ls' = List.rev ls' in List.map (fun (x, xs) -> x, List.rev xs) ls' + +let rec range a b = + if a < b then a :: range (a+1) b + else [] diff --git a/virt-df/virt_df.mli b/virt-df/virt_df.mli index b36d003..d40c934 100644 --- a/virt-df/virt_df.mli +++ b/virt-df/virt_df.mli @@ -212,3 +212,8 @@ val list_lvs : lvm_plugin_id -> device list -> lv list val group_by : ?cmp:('a -> 'a -> int) -> ('a * 'b) list -> ('a * 'b list) list (** Group a sorted list of pairs by the first element of the pair. *) + +val range : int -> int -> int list +(** [range a b] returns the list of integers [a <= i < b]. + If [a >= b] then the empty list is returned. +*)