PROLOG 2-3-TREE PACKAGE Contributed by Mark Johnson Shelved on the 16th of October 1992 The procedures in this file manipulate finite maps from keys to values. Because 2-3 trees are used, they automatically rebalance after each insertion or deletion. Example: ?- list_to_23( [ cat-dog, hare-rabbit, "hair"-"fur", king-queen, exp(1)-2.71828, 3.141593-pi ], Tree ), portray_23( Tree ), put_23( 39, Tree, steps, Tree1 ), portray_23( Tree1 ). gives 23 Tree{ 3.141593 - pi cat - dog hare - rabbit king - queen exp(1) - 2.71828 [104, 97, 105, 114] - [102, 117, 114] } 23 Tree{ 3.141593 - pi 39 - steps cat - dog hare - rabbit king - queen exp(1) - 2.71828 [104, 97, 105, 114] - [102, 117, 114] } There is no routine for deleting items from a tree (you can replace them), but it would not be hard to write one. SIZE: 13 kilobytes. CHECKED ON EDINBURGH-COMPATIBLE (POPLOG) PROLOG : yes. PORTABILITY : uses % comments; assumes compare/3 for comparing arbitrary terms. The source file compare_terms.pl in my source for the Logic Programming Tutor provides this. INTERNAL DOCUMENTATION : brief specification of public and private predicates.