Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/system/Basis/Implementation/string.sml
ViewVC logotype

Diff of /sml/trunk/src/system/Basis/Implementation/string.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 651, Thu Jun 1 18:34:03 2000 UTC revision 1148, Fri Mar 15 21:38:57 2002 UTC
# Line 127  Line 127 
127            (* end case *)            (* end case *)
128          end (* concat *)          end (* concat *)
129    
130      (* concatenate a list of strings, using the given separator string *)
131        fun concatWith _ [] = ""
132          | concatWith _ [x] = x
133          | concatWith sep (h :: t) =
134            concat (rev (foldl (fn (x, l) => x :: sep :: l) [h] t, []))
135    
136    (* implode a list of characters into a string *)    (* implode a list of characters into a string *)
137      fun implode [] = ""      fun implode [] = ""
138        | implode cl =  let        | implode cl =  let
# Line 194  Line 200 
200    
201    (* String comparisons *)    (* String comparisons *)
202      fun isPrefix s1 s2 = PreString.isPrefix (s1, s2, 0, size s2)      fun isPrefix s1 s2 = PreString.isPrefix (s1, s2, 0, size s2)
203      fun compare (a, b) = PreString.cmp (a, 0, size a, b, 0, size b)      fun isSuffix s1 s2 =
204      fun collate cmpFn (a, b) = PreString.collate cmpFn (a, 0, size a, b, 0, size b)          let val sz2 = size s2
205            in
206                PreString.isPrefix (s1, s2, sz2 - size s1, sz2)
207            end
208        fun isSubstring s1 s2 =   (* FIXME: should we do KMP or BM here... (?) *)
209            let val sz2 = size s2
210                val stop = sz2 - size s1
211                fun matches_at_or_after i =
212                    i < stop andalso
213                    (PreString.isPrefix (s1, s2, i, sz2) orelse
214                     matches_at_or_after (i + 1))
215            in
216                matches_at_or_after 0
217            end
218    
219        fun compare (a, b) =
220            PreString.cmp (a, 0, size a, b, 0, size b)
221        fun collate cmpFn (a, b) =
222            PreString.collate cmpFn (a, 0, size a, b, 0, size b)
223    
224    (* String greater or equal *)    (* String greater or equal *)
225      fun sgtr (a, b) = let      fun sgtr (a, b) = let

Legend:
Removed from v.651  
changed lines
  Added in v.1148

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0