X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=src%2Futils.mli;h=2679dc9e74945f626aeb639db549c2d1e193c3ee;hb=1aedabd0caf7a0562a3f314dddd13d49e0165c92;hp=6e81215003452a59371b9d6c7cfe55f928cc6b60;hpb=90d14bc151e488972d33eefaac2242d9a6e07578;p=virt-top.git diff --git a/src/utils.mli b/src/utils.mli index 6e81215..2679dc9 100644 --- a/src/utils.mli +++ b/src/utils.mli @@ -25,6 +25,9 @@ val (//) : string -> string -> string (* failwithf is a printf-like version of failwith. *) val failwithf : ('a, unit, string, 'b) format4 -> 'a +(* Return the list of integers [a..b] (inclusive). *) +val range : int -> int -> int list + (* Read a configuration file as a list of (lineno, key, value) pairs. * If the config file is missing this returns an empty list. *) @@ -33,6 +36,12 @@ val read_config_file : string -> (int * string * string) list (* Pad or truncate a string to a fixed width. *) val pad : int -> string -> string +(* Take up to n elements of xs, if available. *) +val list_take : int -> 'a list -> 'a list + +(* Apply function f to [Some v], return default for [None] *) +val map_default : ('a -> 'b) -> 'b -> 'a option -> 'b + (* Int64 operators for convenience. *) val (+^) : int64 -> int64 -> int64 val (-^) : int64 -> int64 -> int64