src/Pure/General/table.ML
changeset 17179 28802c8a9816
parent 17140 5be3a21ec949
child 17222 819bc7f22423
equal deleted inserted replaced
17178:18a98ecc6821 17179:28802c8a9816
    33   val forall: (key * 'a -> bool) -> 'a table -> bool
    33   val forall: (key * 'a -> bool) -> 'a table -> bool
    34   val defined: 'a table -> key -> bool
    34   val defined: 'a table -> key -> bool
    35   val lookup: 'a table * key -> 'a option
    35   val lookup: 'a table * key -> 'a option
    36   val update: (key * 'a) * 'a table -> 'a table
    36   val update: (key * 'a) * 'a table -> 'a table
    37   val update_new: (key * 'a) * 'a table -> 'a table                    (*exception DUP*)
    37   val update_new: (key * 'a) * 'a table -> 'a table                    (*exception DUP*)
    38   val default: key -> 'a -> 'a table -> 'a table
    38   val default: key * 'a -> 'a table -> 'a table
    39   val map_entry: key -> ('a -> 'a) -> 'a table -> 'a table
    39   val map_entry: key -> ('a -> 'a) -> 'a table -> 'a table
    40   val make: (key * 'a) list -> 'a table                                (*exception DUPS*)
    40   val make: (key * 'a) list -> 'a table                                (*exception DUPS*)
    41   val extend: 'a table * (key * 'a) list -> 'a table                   (*exception DUPS*)
    41   val extend: 'a table * (key * 'a) list -> 'a table                   (*exception DUPS*)
    42   val join: (key -> 'a * 'a -> 'a option) ->
    42   val join: (key -> 'a * 'a -> 'a option) ->
    43     'a table * 'a table -> 'a table                                    (*exception DUPS*)
    43     'a table * 'a table -> 'a table                                    (*exception DUPS*)
   202     handle SAME => tab
   202     handle SAME => tab
   203   end;
   203   end;
   204 
   204 
   205 fun update ((key, x), tab) = modify key (fn _ => x) tab;
   205 fun update ((key, x), tab) = modify key (fn _ => x) tab;
   206 fun update_new ((key, x), tab) = modify key (fn NONE => x | SOME _ => raise DUP key) tab;
   206 fun update_new ((key, x), tab) = modify key (fn NONE => x | SOME _ => raise DUP key) tab;
   207 fun default key x tab = if defined tab key then tab else update ((key, x), tab)
   207 fun default (p as (key, x)) tab = if defined tab key then tab else update (p, tab)
   208 fun map_entry key f = modify key (fn NONE => raise SAME | SOME x => f x);
   208 fun map_entry key f = modify key (fn NONE => raise SAME | SOME x => f x);
   209 
   209 
   210 
   210 
   211 (* extend and make *)
   211 (* extend and make *)
   212 
   212