summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2008-04-15 22:31:08 +0100
committerRichard W.M. Jones <rjones@redhat.com>2008-04-15 22:31:08 +0100
commitb06f8da33e1e87a64ec785e248e47e47fee9073f (patch)
tree4d7b5183934fe9129367fb78b46ee599cd319184
parent3ae5297d795db6e8da8c9b02a7e85a808a93388e (diff)
downloadvirt-top-b06f8da33e1e87a64ec785e248e47e47fee9073f.zip
virt-top-b06f8da33e1e87a64ec785e248e47e47fee9073f.tar.gz
virt-top-b06f8da33e1e87a64ec785e248e47e47fee9073f.tar.xz
Added range library function.
-rw-r--r--virt-df/virt_df.ml4
-rw-r--r--virt-df/virt_df.mli5
2 files changed, 9 insertions, 0 deletions
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.
+*)