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 /smlnj-lib/trunk/Util/int-list-set.sml
ViewVC logotype

Diff of /smlnj-lib/trunk/Util/int-list-set.sml

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

revision 3716, Sat Mar 10 23:44:59 2012 UTC revision 3717, Mon Mar 26 10:59:31 2012 UTC
# Line 77  Line 77 
77              union (l, items')              union (l, items')
78            end            end
79    
80        fun subtract (l, item) = let
81              fun f ([], _) = l
82                | f (elem::r, prefix) = (case Key.compare(item, elem)
83                       of LESS => l
84                        | EQUAL => List.revAppend(prefix, r)
85                        | GREATER => f (r, elem::prefix)
86                      (* end case *))
87              in
88                f (l, [])
89              end
90        fun subtract' (item, l) = subtract (l, item)
91    
92        fun subtractList (l, items) = let
93              val items' = List.foldl (fn (x, set) => add(set, x)) [] items
94              in
95                difference (l, items')
96              end
97    
98    (* create a set from a list of items; this function works in linear time if the list    (* create a set from a list of items; this function works in linear time if the list
99     * is in increasing order.     * is in increasing order.
100     *)     *)

Legend:
Removed from v.3716  
changed lines
  Added in v.3717

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