defining a binary operation

21 views
Skip to first unread message

G. M.-S.

unread,
Jan 12, 2022, 9:06:28 PM1/12/22
to sage-s...@googlegroups.com

Hello.

Is it possible to define a binary operation ∪ such that
A ∪ B
gives
A.union(B)
with the latter taking care of all problems (not a Set, etc.)?

And if so, would it be possible to have an n-ary operation (n > 1) such that for instance
A ∪ B ∪ C
gives
A.union(B).union(C)
without having to write (A ∪ B) ∪ C ?

Guillermo

G. M.-S.

unread,
Jan 12, 2022, 9:09:28 PM1/12/22
to sage-s...@googlegroups.com

Sorry, I just noticed that A+B works.

What about intersections? A*B does not seem to be implemented.

G. M.-S.

unread,
Jan 12, 2022, 10:20:01 PM1/12/22
to sage-s...@googlegroups.com

I have found that modifying

local/lib/python3.9/site-packages/sage/sets/set.py

by adding in
class Set_add_sub_operators:
the lines
    def _mul_(self, X):
        """
        Return the intersection of ``self`` and ``X``.
        """
        return self.intersection(X)
works, but this is temporary and I am not sure it is the right way.

I am aware of the overloading in real_set.py, but it seems they are compatible?

Help welcome.
Reply all
Reply to author
Forward
0 new messages