aboutsummaryrefslogtreecommitdiffstats
path: root/lib/concepts/Path.ml
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-07-11 00:51:11 -0300
committerGitHub <noreply@github.com>2026-07-11 00:51:11 -0300
commitbb3156b8ab78b035ce886bbe3021ec7cbe269d03 (patch)
tree82dd52655d25e49519a035f1245c703e910a2152 /lib/concepts/Path.ml
parent85bff2fc22a131cce5ec2b4eb4b3dd8269c247cd (diff)
downloadRNT-bb3156b8ab78b035ce886bbe3021ec7cbe269d03.tar.gz
RNT-bb3156b8ab78b035ce886bbe3021ec7cbe269d03.zip
FOL: First Order Logic Execution Engine
Co-authored-by: Estevan Castilho <tevo@riajuu.net>
Diffstat (limited to '')
-rw-r--r--lib/concepts/Path.ml16
-rw-r--r--lib/concepts/Path.mli8
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/concepts/Path.ml b/lib/concepts/Path.ml
new file mode 100644
index 0000000..c751301
--- /dev/null
+++ b/lib/concepts/Path.ml
@@ -0,0 +1,16 @@
+type t = string BatFingerTree.t
+
+let empty : t = BatFingerTree.empty
+let of_list (components : string list) : t = BatFingerTree.of_list components
+let to_list (path : t) : string list = BatFingerTree.to_list path
+let snoc (path : t) (component : string) : t = BatFingerTree.snoc path component
+let to_string (path : t) : string = String.concat "/" (to_list path)
+
+let is_prefix ~(prefix : t) (path : t) : bool =
+ let rec walk prefix path =
+ match prefix, path with
+ | [], _ -> true
+ | p :: prefix, x :: path -> p = x && walk prefix path
+ | _ :: _, [] -> false
+ in
+ walk (to_list prefix) (to_list path)
diff --git a/lib/concepts/Path.mli b/lib/concepts/Path.mli
new file mode 100644
index 0000000..bec4221
--- /dev/null
+++ b/lib/concepts/Path.mli
@@ -0,0 +1,8 @@
+type t = string BatFingerTree.t
+
+val empty : t
+val of_list : string list -> t
+val to_list : t -> string list
+val snoc : t -> string -> t
+val to_string : t -> string
+val is_prefix : prefix:t -> t -> bool