From adefca12f83d73986b0f860621232b17c130c742 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sat, 30 May 2009 13:29:00 -0400 Subject: Substring functions; fix a nasty MonoReduce pattern match substitution bug --- lib/ur/string.ur | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/ur/string.ur') 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}) -- cgit v1.2.3