Re: transitive closure

From: Neo <neo55592_at_hotmail.com>
Date: 18 Jul 2005 08:38:32 -0700
Message-ID: <1121701112.511420.226800_at_g47g2000cwa.googlegroups.com>


The xrdb script below creates a small hierarchy and then traverses it with SELECTR command. The same methodology can be applied to larger hierarchies.

// Create universe
// and make it an item of main directory.
(CREATE type inst *universe & dir item it)

// Create planets.
(CREATE type inst *planet)
(CREATE planet inst *mars)
(CREATE planet inst *venus)

// Create persons.
(CREATE type inst *person)
(CREATE person inst *john)
(CREATE person inst *mary)

// Create hierarchy.
(CREATE universe part mars)
(CREATE universe part venus)

(CREATE mars part john)
(CREATE venus part mary)

// Find a part of Mars that is a person. // Finds John.
(SELECT mars part * & person inst *)

// Find parts of universe.
// Finds Mars and Venus.
(SELECT universe part *)

// Find parts of universe recursively.
// Finds Mars, John, Venus and Mary.
(SELECTR universe part)

As the philosopher Schopenhauer said, 'All truth goes through three stages. First, it is ridiculed. Then, it is violently opposed. Finally, it is accepted as self-evident.' Received on Mon Jul 18 2005 - 17:38:32 CEST

Original text of this message