summaryrefslogtreecommitdiff
path: root/src/util.ml
diff options
context:
space:
mode:
authorAlasdair Armstrong2017-09-07 17:09:33 +0100
committerAlasdair Armstrong2017-09-07 17:09:33 +0100
commit97ebda8681ec38d6e087abe04629255420991a40 (patch)
treefa2c52eff75b31f4d5e2b81ad68484266be2dfe5 /src/util.ml
parent842165c1171fde332bd42e7520338c59a797f76b (diff)
parent2625f48417d25ab0493884b2f934887b86d568ab (diff)
Merge branch 'experiments' of https://bitbucket.org/Peter_Sewell/sail into experiments
Diffstat (limited to 'src/util.ml')
-rw-r--r--src/util.ml9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/util.ml b/src/util.ml
index c89cc1ef..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