Mercurial > urweb
view lib/ur/string.ur @ 956:d80734855790
Don't try to check if functions are already tail-recursive
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 17 Sep 2009 17:17:49 -0400 |
parents | 5e1a4b12c83a |
children | e46227efcbba |
line wrap: on
line source
type t = Basis.string val length = Basis.strlen val append = Basis.strcat val sub = Basis.strsub 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 = 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}) 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})