diff options
author | 2009-05-30 13:29:00 -0400 | |
---|---|---|
committer | 2009-05-30 13:29:00 -0400 | |
commit | adefca12f83d73986b0f860621232b17c130c742 (patch) | |
tree | ff01535ec8b49034e5cb39f0be1e36261bea9d8b /lib/ur/string.ur | |
parent | 0ee7bc2859f77d610ef4a8edd2acce8e5e0fe58c (diff) |
Substring functions; fix a nasty MonoReduce pattern match substitution bug
Diffstat (limited to 'lib/ur/string.ur')
-rw-r--r-- | lib/ur/string.ur | 11 |
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}) |