summaryrefslogtreecommitdiff
path: root/lib/ur/string.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-05-30 13:29:00 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-05-30 13:29:00 -0400
commit54276f5a38163eb7997c574810faed0cc6dea35c (patch)
treeff01535ec8b49034e5cb39f0be1e36261bea9d8b /lib/ur/string.ur
parent581a2290590268039cacfbe0762b343f710c3116 (diff)
Substring functions; fix a nasty MonoReduce pattern match substitution bug
Diffstat (limited to 'lib/ur/string.ur')
-rw-r--r--lib/ur/string.ur11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/ur/string.ur b/lib/ur/string.ur
index 23670966..e6d5903e 100644
--- a/lib/ur/string.ur
+++ b/lib/ur/string.ur
@@ -5,3 +5,14 @@ val append = Basis.strcat
val sub = Basis.strsub
val suffix = Basis.strsuffix
+
+val index = Basis.strindex
+val atFirst = Basis.strchr
+
+fun substring s {Start = start, Len = len} = Basis.substring s start len
+
+fun split s ch =
+ case index s ch of
+ None => None
+ | Some i => Some (substring s {Start = 0, Len = i},
+ substring s {Start = i + 1, Len = length s - i - 1})