X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=utils.ml;h=87c4002bbdcdabc58d66010ff25aeae21a764e4d;hb=c0fda8a7fcb16baebb00310e30f1b1f90a0d0c05;hp=fd92b790ac8e9bade84df6de4eb5fbfcba440cb0;hpb=b29a837444aa5827b683bee5a7457fbb32305ae5;p=mclu.git diff --git a/utils.ml b/utils.ml index fd92b79..87c4002 100644 --- a/utils.ml +++ b/utils.ml @@ -33,6 +33,13 @@ let ( /^ ) = Int64.div let ( &^ ) = Int64.logand let ( ~^ ) = Int64.lognot +let rec filter_map f = function + | [] -> [] + | x :: xs -> + match f x with + | Some y -> y :: filter_map f xs + | None -> filter_map f xs + let human_size i = let sign, i = if i < 0L then "-", Int64.neg i else "", i in