summaryrefslogtreecommitdiff
path: root/src/Utilities.ml
diff options
context:
space:
mode:
authorSon Ho2021-11-23 10:33:59 +0100
committerSon Ho2021-11-23 10:33:59 +0100
commit5868e99535a02b3cba93e3ed983008642bbde815 (patch)
tree8d9a18b519cac21cbb1e809847bdd6349360062e /src/Utilities.ml
parentef96428f8babb67999d73762cf5a087946e78404 (diff)
Implement expand_bottom_value
Diffstat (limited to '')
-rw-r--r--src/Utilities.ml15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Utilities.ml b/src/Utilities.ml
new file mode 100644
index 00000000..84cbd6e9
--- /dev/null
+++ b/src/Utilities.ml
@@ -0,0 +1,15 @@
+(* Split a list at a given index i (the first list contains all the elements
+ up to element of index i, not included, the second one contains the remaining
+ elements *)
+let rec list_split_at (ls : 'a list) (i : int) =
+ if i < 0 then raise (Invalid_argument "list_split_at take positive integers")
+ else if i = 0 then ([], ls)
+ else
+ match ls with
+ | [] ->
+ raise
+ (Failure
+ "The int given to list_split_at should be <= the list's length")
+ | x :: ls' ->
+ let ls1, ls2 = list_split_at ls' (i - 1) in
+ (x :: ls1, ls2)