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/HashCons/hash-cons-map.sml
ViewVC logotype

Diff of /smlnj-lib/trunk/HashCons/hash-cons-map.sml

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

revision 6158, Fri Apr 10 23:22:07 2020 UTC revision 6159, Sat Apr 11 13:14:51 2020 UTC
# Line 45  Line 45 
45            end            end
46    
47      fun find (map : ('a, 'b) map, obj) = Option.map #2 (Map.find(map, HC.tag obj))      fun find (map : ('a, 'b) map, obj) = Option.map #2 (Map.find(map, HC.tag obj))
48        fun lookup (map : ('a, 'b) map, obj) = #2 (Map.lookup(map, HC.tag obj))
49      fun inDomain (map, obj) = Map.inDomain (map, HC.tag obj)      fun inDomain (map, obj) = Map.inDomain (map, HC.tag obj)
50      fun remove (map, obj) = let      fun remove (map, obj) = let
51            val (map, (_, v)) = Map.remove (map, HC.tag obj)            val (map, (_, v)) = Map.remove (map, HC.tag obj)
# Line 66  Line 67 
67            Map.intersectWith (fn ((k, a), (_, b)) => (k, join(a, b)))            Map.intersectWith (fn ((k, a), (_, b)) => (k, join(a, b)))
68      fun intersectWithi join =      fun intersectWithi join =
69            Map.intersectWithi (lift2i (fn (k, a, b) => (k, join(k, a, b))))            Map.intersectWithi (lift2i (fn (k, a, b) => (k, join(k, a, b))))
70        fun mergeWith join = let
71              fun result (k, SOME c) = SOME(k, c)
72                | result (_, NONE) = NONE
73              fun join' (SOME(k, a), SOME(_, b)) = result (k, join(SOME a, SOME b))
74                | join' (SOME(k, a), NONE) = result (k, join(SOME a, NONE))
75                | join' (NONE, SOME(k, b)) = result (k, join(NONE, SOME b))
76                | join' (NONE, NONE) = raise Fail "impossible"
77              in
78                Map.mergeWith join'
79              end
80        fun mergeWithi join = let
81              fun result (k, SOME c) = SOME(k, c)
82                | result (_, NONE) = NONE
83              fun join' (SOME(k, a), SOME(_, b)) = result (k, join(k, SOME a, SOME b))
84                | join' (SOME(k, a), NONE) = result (k, join(k, SOME a, NONE))
85                | join' (NONE, SOME(k, b)) = result (k, join(k, NONE, SOME b))
86                | join' (NONE, NONE) = raise Fail "impossible"
87              in
88                Map.mergeWith join'
89              end
90      fun app f = Map.app (fn (_, v) => f v)      fun app f = Map.app (fn (_, v) => f v)
91      val appi = Map.app      val appi = Map.app
92      fun map f = Map.map (fn (k, v) => (k, f v))      fun map f = Map.map (fn (k, v) => (k, f v))
93      fun mapi f = Map.map (fn (k, v) => (k, f(k, v)))      fun mapi f = Map.map (fn (k, v) => (k, f(k, v)))
94      fun foldl f = Map.foldl (fn ((_, x), acc) => f(x, acc))      fun fold f = Map.foldl (fn ((_, x), acc) => f(x, acc))
95      fun foldli f = Map.foldl (fn ((k, x), acc) => f(k, x, acc))      fun foldi f = Map.foldl (fn ((k, x), acc) => f(k, x, acc))
96      fun foldr f = Map.foldr (fn ((_, x), acc) => f(x, acc))      val foldl = fold    (* DEPRECATED *)
97      fun foldri f = Map.foldr (fn ((k, x), acc) => f(k, x, acc))      val foldli = foldi  (* DEPRECATED *)
98        val foldr = fold    (* DEPRECATED *)
99        val foldri = foldi  (* DEPRECATED *)
100      fun filter pred = Map.filter (fn (_, x) => pred x)      fun filter pred = Map.filter (fn (_, x) => pred x)
101      val filteri = Map.filter      val filteri = Map.filter
102      fun mapPartial f =      fun mapPartial f =
# Line 82  Line 105 
105      fun mapPartiali f =      fun mapPartiali f =
106            Map.mapPartial            Map.mapPartial
107              (fn (k, v) => case f(k, v) of SOME v => SOME(k, v) | NONE => NONE)              (fn (k, v) => case f(k, v) of SOME v => SOME(k, v) | NONE => NONE)
108        fun exists f = Map.exists (fn (k, v) => f v)
109        fun existsi f = Map.exists f
110        fun all f = Map.all (fn (k, v) => f v)
111        fun alli f = Map.all f
112    
113    end    end

Legend:
Removed from v.6158  
changed lines
  Added in v.6159

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