aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/ur/string.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-01-13 10:02:50 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2011-01-13 10:02:50 -0500
commit24c29015ba668b044be7428f69058687a56d6a06 (patch)
treead413eedbc7c3eed30a276f339d9adf87ff01e49 /lib/ur/string.ur
parent4eb2a196fa24d52462f3f325d73952fe2d1c12cd (diff)
More string processing
Diffstat (limited to 'lib/ur/string.ur')
-rw-r--r--lib/ur/string.ur7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/ur/string.ur b/lib/ur/string.ur
index a93f7a57..59a8e5c5 100644
--- a/lib/ur/string.ur
+++ b/lib/ur/string.ur
@@ -10,6 +10,7 @@ val sub = Basis.strsub
val suffix = Basis.strsuffix
val index = Basis.strindex
+fun sindex r = Basis.strsindex r.Haystack r.Needle
val atFirst = Basis.strchr
fun mindex {Haystack = s, Needle = chs} =
@@ -50,6 +51,12 @@ fun msplit {Haystack = s, Needle = chs} =
sub s i,
suffix s (i + 1))
+fun ssplit r =
+ case sindex r of
+ None => None
+ | Some i => Some (substring r.Haystack {Start = 0, Len = i},
+ suffix r.Haystack (i + length r.Needle))
+
fun all f s =
let
val len = length s