diff options
| author | Brian Campbell | 2017-09-04 12:09:59 +0100 |
|---|---|---|
| committer | Brian Campbell | 2017-09-04 12:09:59 +0100 |
| commit | 00cf8533221d2dfa650adcd38ac53943be5bd995 (patch) | |
| tree | 21a34e1f094ecec430798020e046dd3374e6e74c /src/util.ml | |
| parent | 461f3c914b2e767ef3ddb926712845d5442475f3 (diff) | |
| parent | de506ed9f9c290796f159f2b5279589519c2a198 (diff) | |
Merge branch 'experiments' of bitbucket.org:Peter_Sewell/sail into mono-experiments
Diffstat (limited to 'src/util.ml')
| -rw-r--r-- | src/util.ml | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/util.ml b/src/util.ml index 75732376..335fd36f 100644 --- a/src/util.ml +++ b/src/util.ml @@ -86,6 +86,15 @@ (* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *) (**************************************************************************) +let rec last = function + | [x] -> x + | _ :: xs -> last xs + | [] -> raise (Failure "last") + +let rec butlast = function + | [x] -> [] + | x :: xs -> x :: butlast xs + | [] -> [] module Duplicate(S : Set.S) = struct @@ -204,10 +213,8 @@ let option_bind f = function | Some(o) -> f o let rec option_binop f x y = match x, y with - | None, None -> None - | Some x, None -> Some x - | None, Some y -> Some y | Some x, Some y -> Some (f x y) + | _ -> None let changed2 f g x h y = match (g x, h y) with |
