# HG changeset patch # User clasohm # Date 774267845 -7200 # Node ID bf2f285aa316b58cfa10d4a3a128f73382326ea2 # Parent ac1d1988d5280798ea49f789a1e3e757687d2c63 added function mapst diff -r ac1d1988d528 -r bf2f285aa316 src/Pure/symtab.ML --- 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