Relation class

Does anyone know of a Relation class with methods such as
domain
range
add
remove
image
inverse_image
compose
inverse_compose
inverse
override

etc.?

Thanks.

In article a6e48b6b.0306062001.42039e1a@posting.google.com,

···

you CAN teach an old dog … itsme213@hotmail.com wrote:

Does anyone know of a Relation class with methods such as
domain
range
add
remove
image
inverse_image
compose
inverse_compose
inverse
override

I don’t know of one, but it would be nice to have one…

Phil

If the relation is a function (in the mathematical sense) you can
basically use a Hash.

domain => keys
range => values
add => = w/ some wrapping
remove => delete
image =>
etc

however inverse_image would be O(n) so probably something with two
hashes is better.

Is the relation supposed to be

  1. injective
  2. surjective
  3. both (bijective) ???

If (1) doesn’t hold you’ll have to wrap the methods of Hash so that each
value is an array, but things get more difficult if (2) is not
guaranteed.

···

On Sat, Jun 07, 2003 at 01:09:10PM +0900, you CAN teach an old dog … wrote:

Does anyone know of a Relation class with methods such as
domain
range
add
remove
image
inverse_image
compose
inverse_compose
inverse
override


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Netscape is not a newsreader, and probably never shall be.
– Tom Christiansen