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/comp-lib/intmapf.sml
 [smlnj] / sml / trunk / src / comp-lib / intmapf.sml

# Diff of /sml/trunk/src/comp-lib/intmapf.sml

revision 121, Sat Jun 6 15:03:25 1998 UTC revision 122, Sat Jun 6 15:05:38 1998 UTC
# Line 17  Line 17
17    val cardinality : 'a intmap -> int    val cardinality : 'a intmap -> int
18    val difference : 'a intmap * 'b intmap -> 'a intmap    val difference : 'a intmap * 'b intmap -> 'a intmap
19    val delete : int * 'a intmap -> 'a intmap    val delete : int * 'a intmap -> 'a intmap
20      val fold : (int * 'a * 'b -> 'b) -> 'b -> 'a intmap -> 'b
21  end  end
22
23  (*  (*
# Line 164  Line 165
165                  else if weight*n2 < n1 then T'(v1,v1',l1,concat(r1,t2))                  else if weight*n2 < n1 then T'(v1,v1',l1,concat(r1,t2))
166                       else cat2(t1,t2)                       else cat2(t1,t2)
167
fun fold(f,base,set) =
let fun fold'(base,E) = base
| fold'(base,T(v,v',_,l,r)) = fold'(f((v,v'),fold'(base,r)),l)
in
fold'(base,set)
end

168          in          in
169
170              type  'a intmap = 'a Map              type  'a intmap = 'a Map
# Line 207  Line 201
201                          if x<v then mem l else if x>v then mem r else v'                          if x<v then mem l else if x>v then mem r else v'
202                  in mem set end                  in mem set end
203
204              fun members set = fold(op::,[],set)              fun fold f base map =
205                    let fun fold' (base,E) = base
206                          | fold' (base,T(v,v',_,l,r)) =
207                            fold'(fold'(f(v, v', base), l), r)
208                    in
209                        fold'(base, map)
210                    end
211
212                fun members m = fold (fn (i,v,res) => (i,v)::res) [] m
213
214              fun cardinality E = 0              fun cardinality E = 0
215                | cardinality (T(_,_,n,_,_)) = n                | cardinality (T(_,_,n,_,_)) = n

Legend:
 Removed from v.121 changed lines Added in v.122