annotate lib/ur/string.ur @ 1023:e46227efcbba

Bidding interface
author Adam Chlipala <adamc@hcoop.net>
date Sun, 01 Nov 2009 10:20:20 -0500
parents 5e1a4b12c83a
children eaba663fd6aa
rev   line source
adamc@821 1 type t = Basis.string
adamc@821 2
adamc@1023 3 val str = Basis.str1
adamc@1023 4
adamc@828 5 val length = Basis.strlen
adamc@828 6 val append = Basis.strcat
adamc@828 7
adamc@821 8 val sub = Basis.strsub
adamc@821 9 val suffix = Basis.strsuffix
adamc@829 10
adamc@829 11 val index = Basis.strindex
adamc@829 12 val atFirst = Basis.strchr
adamc@829 13
adamc@831 14 fun mindex {Haystack = s, Needle = chs} = Basis.strcspn s chs
adamc@831 15
adamc@829 16 fun substring s {Start = start, Len = len} = Basis.substring s start len
adamc@829 17
adamc@829 18 fun split s ch =
adamc@829 19 case index s ch of
adamc@829 20 None => None
adamc@829 21 | Some i => Some (substring s {Start = 0, Len = i},
adamc@829 22 substring s {Start = i + 1, Len = length s - i - 1})
adamc@831 23 fun msplit {Haystack = s, Needle = chs} =
adamc@831 24 case mindex {Haystack = s, Needle = chs} of
adamc@831 25 None => None
adamc@831 26 | Some i => Some (substring s {Start = 0, Len = i},
adamc@831 27 sub s i,
adamc@831 28 substring s {Start = i + 1, Len = length s - i - 1})