From b06f8da33e1e87a64ec785e248e47e47fee9073f Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 1 Jan 1970 00:00:00 +0000 Subject: [PATCH] Added range library function. --- virt-df/virt_df.ml | 4 ++++ virt-df/virt_df.mli | 5 +++++ 2 files changed, 9 insertions(+) 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. +*) -- 1.8.3.1