From 4eb2a196fa24d52462f3f325d73952fe2d1c12cd Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 11 Jan 2011 18:04:52 -0500 Subject: Some more string parsing functions; naughtyDebug --- lib/ur/string.ur | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'lib/ur/string.ur') diff --git a/lib/ur/string.ur b/lib/ur/string.ur index 235e5939..a93f7a57 100644 --- a/lib/ur/string.ur +++ b/lib/ur/string.ur @@ -24,17 +24,31 @@ fun mindex {Haystack = s, Needle = chs} = fun substring s {Start = start, Len = len} = Basis.substring s start len +fun seek s ch = + case index s ch of + None => None + | Some i => Some (suffix s (i + 1)) +fun mseek {Haystack = s, Needle = chs} = + case mindex {Haystack = s, Needle = chs} of + None => None + | Some i => Some (sub s i, suffix s (i + 1)) + 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}) + suffix s (i + 1)) +fun split' s ch = + case index s ch of + None => None + | Some i => Some (substring s {Start = 0, Len = i}, + suffix s i) fun msplit {Haystack = s, Needle = chs} = case mindex {Haystack = s, Needle = chs} of None => None | Some i => Some (substring s {Start = 0, Len = i}, sub s i, - substring s {Start = i + 1, Len = length s - i - 1}) + suffix s (i + 1)) fun all f s = let -- cgit v1.2.3