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/list-map-fn.sml
ViewVC logotype

Diff of /smlnj-lib/trunk/Util/list-map-fn.sml

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

revision 410, Fri Sep 3 00:25:03 1999 UTC revision 411, Fri Sep 3 00:25:03 1999 UTC
# Line 26  Line 26 
26      fun firsti [] = NONE      fun firsti [] = NONE
27        | firsti ((key, value)::_) = SOME(key, value)        | firsti ((key, value)::_) = SOME(key, value)
28    
29        fun singleton (key, item) = [(key, item)]
30    
31      fun insert (l, key, item) = let      fun insert (l, key, item) = let
32            fun f [] = [(key, item)]            fun f [] = [(key, item)]
33              | f ((elem as (key', _))::r) = (case Key.compare(key, key')              | f ((elem as (key', _))::r) = (case Key.compare(key, key')
# Line 38  Line 40 
40            end            end
41      fun insert' ((k, x), m) = insert(m, k, x)      fun insert' ((k, x), m) = insert(m, k, x)
42    
43      (* return true if the key is in the map's domain *)
44        fun inDomain (l, key) = let
45              fun f [] = false
46                | f ((key', x) :: r) = (case Key.compare(key, key')
47                       of LESS => false
48                        | EQUAL => true
49                        | GREATER => f r
50                      (* end case *))
51              in
52                f l
53              end
54    
55    (* Look for an item, return NONE if the item doesn't exist *)    (* Look for an item, return NONE if the item doesn't exist *)
56      fun find (l, key) = let      fun find (l, key) = let
57            fun f [] = NONE            fun f [] = NONE
# Line 71  Line 85 
85      fun listItems (l : 'a map) = List.map #2 l      fun listItems (l : 'a map) = List.map #2 l
86      fun listItemsi l = l      fun listItemsi l = l
87    
88        fun listKeys (l : 'a map) = List.map #1 l
89    
90      fun collate cmpRng = let      fun collate cmpRng = let
91            fun cmp ([], []) = EQUAL            fun cmp ([], []) = EQUAL
92              | cmp ([], _) = LESS              | cmp ([], _) = LESS

Legend:
Removed from v.410  
changed lines
  Added in v.411

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