comparison lib/ur/string.ur @ 829:20fe00fd81da

Substring functions; fix a nasty MonoReduce pattern match substitution bug
author Adam Chlipala <adamc@hcoop.net>
date Sat, 30 May 2009 13:29:00 -0400
parents 14a6c0971d89
children 5e1a4b12c83a
comparison
equal deleted inserted replaced
828:14a6c0971d89 829:20fe00fd81da
3 val length = Basis.strlen 3 val length = Basis.strlen
4 val append = Basis.strcat 4 val append = Basis.strcat
5 5
6 val sub = Basis.strsub 6 val sub = Basis.strsub
7 val suffix = Basis.strsuffix 7 val suffix = Basis.strsuffix
8
9 val index = Basis.strindex
10 val atFirst = Basis.strchr
11
12 fun substring s {Start = start, Len = len} = Basis.substring s start len
13
14 fun split s ch =
15 case index s ch of
16 None => None
17 | Some i => Some (substring s {Start = 0, Len = i},
18 substring s {Start = i + 1, Len = length s - i - 1})