Source file gsl_misc.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(* gsl-ocaml - OCaml interface to GSL                       *)
(* Copyright (©) 2002-2012 - Olivier Andrieu                *)
(* Distributed under the terms of the GPL version 3         *)


let maybe_or_else o def = 
  match o with
  | None -> def
  | Some v -> v

let may vo f = 
  match vo with
  | None -> ()
  | Some v -> f v

let may_apply fo v =
  match fo with
  | None -> ()
  | Some f -> f v

let is = function
  | None -> false
  | Some _ -> true