[GOODIE] BinaryRelation
Richard A. O'Keefe
ok at cs.otago.ac.nz
Thu Mar 27 22:54:56 UTC 2003
Hannes wrote:
Yes, why not just use a standard Dictionary?
If I have
Element A is related to B (both directions)
I would just do
d _ Dictionary new.
d at: #A put: #B.
d at: #B put: #A.
Am I missing something?
Well, yes. Practically everything, actually.
The point about a Dictionary is that it is a PARTIAL FUNCTION.
For any key, there is AT MOST ONE related value.
The point about a BinaryRelation is that it is a RELATION.
For any "key", there could be any number of related values.
So, supposing you have
{(A,B),(A,C),(A,X),(B,C),(B,M),(C,A),(C,M),(M,X)}
just how do you do that using one standard Dictionary?
d at: #A put: #B. "so far so good"
d at: #A put: #C. "oops! just lost B!"
Also, you can only handle the case you did handle by falsifying
the semantics. Given the relation {(A,B)},
A snarklefests B
is TRUE, but
B snarklefests A
is FALSE, so if
d at: #A put: #B
is an appropriate way of saying that A snarklefests B,
then
d at: #B put: #A
must say that B snarklefests A, which it doesn't.
Being NAVIGABLE in both directions is very very different from
being symmetric. If A snarklefests B, I want to be able to find
A given B, _even_though_B_does_not_snarklefest_A_.
More information about the Squeak-dev
mailing list
|