Skip to content

Instantly share code, notes, and snippets.

@hcarty
Created September 22, 2012 18:00
Show Gist options
  • Save hcarty/3767210 to your computer and use it in GitHub Desktop.
Save hcarty/3767210 to your computer and use it in GitHub Desktop.
Convenience versions of BatBounded functions
let saturate_of_ord ~(bounds : 'a bound_t * 'a bound_t) ord =
match bounds with
| `o l, `o h
| `c l, `c h
| `o l, `c h
| `c l, `o h ->
bounding_of_ord ~default_low:l ~default_high:h ord ~bounds
|- BatOption.get
| `u, `o h
| `u, `c h ->
bounding_of_ord ~default_high:h ord ~bounds
|- BatOption.get
| `o l, `u
| `c l, `u ->
bounding_of_ord ~default_low:l ord ~bounds
|- BatOption.get
| `u, `u ->
bounding_of_ord ord ~bounds
|- BatOption.get
let opt_of_ord ~(bounds : 'a bound_t * 'a bound_t) ord =
bounding_of_ord ord ~bounds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment