src/Pure/General/table.ML
changeset 20141 cf8129ebcdd3
parent 20124 caf3a129b90d
child 21065 42669b5bf98e
equal deleted inserted replaced
20140:98acc6d0fab6 20141:cf8129ebcdd3
    37   val lookup: 'a table -> key -> 'a option
    37   val lookup: 'a table -> key -> 'a option
    38   val update: (key * 'a) -> 'a table -> 'a table
    38   val update: (key * 'a) -> 'a table -> 'a table
    39   val update_new: (key * 'a) -> 'a table -> 'a table                   (*exception DUP*)
    39   val update_new: (key * 'a) -> 'a table -> 'a table                   (*exception DUP*)
    40   val default: key * 'a -> 'a table -> 'a table
    40   val default: key * 'a -> 'a table -> 'a table
    41   val map_entry: key -> ('a -> 'a) -> 'a table -> 'a table
    41   val map_entry: key -> ('a -> 'a) -> 'a table -> 'a table
       
    42   val map_default: (key * 'a) -> ('a -> 'a) -> 'a table -> 'a table
    42   val make: (key * 'a) list -> 'a table                                (*exception DUPS*)
    43   val make: (key * 'a) list -> 'a table                                (*exception DUPS*)
    43   val extend: 'a table * (key * 'a) list -> 'a table                   (*exception DUPS*)
    44   val extend: 'a table * (key * 'a) list -> 'a table                   (*exception DUPS*)
    44   val join: (key -> 'a * 'a -> 'a) (*exception DUP/SAME*) ->
    45   val join: (key -> 'a * 'a -> 'a) (*exception DUP/SAME*) ->
    45     'a table * 'a table -> 'a table                                    (*exception DUPS*)
    46     'a table * 'a table -> 'a table                                    (*exception DUPS*)
    46   val merge: ('a * 'a -> bool) -> 'a table * 'a table -> 'a table      (*exception DUPS*)
    47   val merge: ('a * 'a -> bool) -> 'a table * 'a table -> 'a table      (*exception DUPS*)
   244 
   245 
   245 fun update (key, x) tab = modify key (fn _ => x) tab;
   246 fun update (key, x) tab = modify key (fn _ => x) tab;
   246 fun update_new (key, x) tab = modify key (fn NONE => x | SOME _ => raise DUP key) tab;
   247 fun update_new (key, x) tab = modify key (fn NONE => x | SOME _ => raise DUP key) tab;
   247 fun default (key, x) tab = modify key (fn NONE => x | SOME _ => raise SAME) tab;
   248 fun default (key, x) tab = modify key (fn NONE => x | SOME _ => raise SAME) tab;
   248 fun map_entry key f = modify key (fn NONE => raise SAME | SOME x => f x);
   249 fun map_entry key f = modify key (fn NONE => raise SAME | SOME x => f x);
       
   250 fun map_default (key, x) f = modify key (fn NONE => f x | SOME x => f x);
   249 
   251 
   250 
   252 
   251 (* delete *)
   253 (* delete *)
   252 
   254 
   253 exception UNDEF of key;
   255 exception UNDEF of key;