/* I've got a binary tree full of data, and some other data structure that is supposed to contain the same data in the same order. I want to make sure of that. Easy. I can do an in-order enumeration of the tree, and at each node get the next data item from the other data structure and compare. */ manifest { t_data = 0, t_left = 1, t_right = 2, sizeof_t = 3 } let internal_compare(ptr, other) be // ptr is the pointer to the root node of the tree, // other is some kind of enumerator for the other structure { let ok; if ptr = nil then resultis true; ok := internal_compare(ptr ! t_left, other); if not ok then resultis false; if not equal(ptr ! t_data, getnext(other)) then resultis false; ok := internal_compare(ptr ! t_right, other); resultis ok } let compare(tree, otherthing) be { let enum = enumerator(otherthing); let ok = internal_compare(tree, enum); if not ok then resultis false; if not empty(enum) then resultis false; resultis true }