--- a/src/Pure/symtab.ML Thu Jul 14 11:39:25 1994 +0200
+++ b/src/Pure/symtab.ML Fri Jul 15 12:24:05 1994 +0200
@@ -16,6 +16,7 @@
val lookup: 'a table * string -> 'a option
val update: (string * 'a) * 'a table -> 'a table
val update_new: (string * 'a) * 'a table -> 'a table
+ val mapst: ('a -> 'a) -> 'a table -> 'a table
val alist_of: 'a table -> (string * 'a) list
val balance: 'a table -> 'a table
val st_of_alist: (string * 'a) list * 'a table -> 'a table
@@ -54,6 +55,7 @@
else Some entry
in look symtab end;
+
(*update, allows overwriting of an entry*)
fun update ((key: string, entry: 'a), symtab : 'a table)
: 'a table =
@@ -75,6 +77,15 @@
else raise DUPLICATE(key)
in upd symtab end;
+
+(*Similar to map this applies a function f to every entry in symtab*)
+fun mapst f symtab =
+ let fun apply Tip = Tip
+ | apply (Branch (key, entry, left, right)) =
+ Branch (key, f entry, apply left, apply right);
+ in apply symtab end;
+
+
(*conversion of symbol table to sorted association list*)
fun alist_of (symtab : 'a table) : (string * 'a) list =
let fun ali (symtab, cont) = case symtab of