diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-05-31 12:41:34 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-05-31 12:41:34 -0400 |
commit | a6424094365f7d63b6c9dade8f8f72ef26e92b45 (patch) | |
tree | 4eac927486b596ee7118f84c2dc468489840e98d /lib/ur/string.ur | |
parent | bd0d3db78996b00e153252f03b02551ac3fde4cf (diff) |
strcspn and friends
Diffstat (limited to 'lib/ur/string.ur')
-rw-r--r-- | lib/ur/string.ur | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/ur/string.ur b/lib/ur/string.ur index e6d5903e..e31bbc27 100644 --- a/lib/ur/string.ur +++ b/lib/ur/string.ur @@ -9,6 +9,8 @@ val suffix = Basis.strsuffix val index = Basis.strindex val atFirst = Basis.strchr +fun mindex {Haystack = s, Needle = chs} = Basis.strcspn s chs + fun substring s {Start = start, Len = len} = Basis.substring s start len fun split s ch = @@ -16,3 +18,9 @@ fun split s ch = None => None | Some i => Some (substring s {Start = 0, Len = i}, substring s {Start = i + 1, Len = length s - i - 1}) +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}) |