src/Pure/General/table.ML
changeset 15574 b1d1b5bfc464
parent 15570 8d8c70b41bab
child 15665 7e7412fffc0c
equal deleted inserted replaced
15573:cf53c2dcf440 15574:b1d1b5bfc464
   285 (* tables with multiple entries per key (preserving order) *)
   285 (* tables with multiple entries per key (preserving order) *)
   286 
   286 
   287 fun lookup_multi tab_key = getOpt (lookup tab_key,[]);
   287 fun lookup_multi tab_key = getOpt (lookup tab_key,[]);
   288 fun update_multi ((key, x), tab) = update ((key, x :: lookup_multi (tab, key)), tab);
   288 fun update_multi ((key, x), tab) = update ((key, x :: lookup_multi (tab, key)), tab);
   289 
   289 
   290 fun make_multi pairs = Library.foldr update_multi (pairs, empty);
   290 fun make_multi pairs = foldr update_multi empty pairs;
   291 fun dest_multi tab = List.concat (map (fn (key, xs) => map (Library.pair key) xs) (dest tab));
   291 fun dest_multi tab = List.concat (map (fn (key, xs) => map (Library.pair key) xs) (dest tab));
   292 fun merge_multi eq tabs = join (fn (xs, xs') => SOME (gen_merge_lists eq xs xs')) tabs;
   292 fun merge_multi eq tabs = join (fn (xs, xs') => SOME (gen_merge_lists eq xs xs')) tabs;
   293 fun merge_multi' eq tabs = join (fn (xs, xs') => SOME (gen_merge_lists' eq xs xs')) tabs;
   293 fun merge_multi' eq tabs = join (fn (xs, xs') => SOME (gen_merge_lists' eq xs xs')) tabs;
   294 
   294 
   295 
   295