SET functions

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

SET functions

Message par compsystems » jeu. déc. 13, 2018 6:09 pm

Hi, BP
Does GIAC have functions to determine if one set is a subset of another? In addition, if an element belongs or not to a set and function to make the product Cartesian.

Thanks

parisse
Messages : 5740
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: SET functions

Message par parisse » jeu. déc. 13, 2018 6:36 pm

is_element(1,[1,2,3]) or contains([1,2,3],1)
set[1,2]*set[3,4]

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: SET functions

Message par compsystems » lun. déc. 17, 2018 3:30 am

thanks ^

and these two basic functions

Complement of a set and
Symmetric difference of sets

parisse
Messages : 5740
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: SET functions

Message par parisse » lun. déc. 17, 2018 6:36 am

minus
I would appreciate if you could take a look at the help and documentation before posting. I mean if you open the Prg>Set menu you will see the minus command or if you open Help>Index for union, you will see in "See also" intersect and minus.

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: SET functions

Message par compsystems » lun. déc. 17, 2018 2:17 pm

I mean the functions

Symmetric difference of sets: M Δ N
Complement of a set:
M' U
N' U

M:= set[ "A", "B", "C"]
N:= set[ "B", "G", "L", "E"]
U:= set[ "A", "B", "C", "G", "L", "E", "I", "J", "F", "H"]

M union N [↵] set["A","B","C","G","L","E"]
M intersect N [↵] set["B"]
M minus N [↵] set["A","C"]
M Δ N [↵] set[ "A", "C", "G", "L", "E"]
M' U [↵] set[ "J", "F", "G", "L", "E", "I", "H"]
N' U [↵] set[ "I", "H", "J", "F", "A", "C" ]

parisse
Messages : 5740
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: SET functions

Message par parisse » lun. déc. 17, 2018 2:59 pm

I mean you can use minus for complementary and for the symmetric difference.

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: SET functions

Message par compsystems » lun. déc. 17, 2018 4:54 pm

ok
Δ (Symmetric difference ) = (N minus M) union (M minus N)

//
In the help of XCAS-PC says that
is_element() Returns 1 if the point is on the geometric object and 0 otherwise.

You can apply this characteristic in sets object, that is, instead of returning the position (#), return a true / false symbolic value,
Since there are functions that return the position of an element
contains("a",set["b","a","c","a"]) [↵] 2
contains("d",set["b","a","c","a"]) [↵] 0

is_element("a",set["b","a","c","a"]) [↵] 2 => true
is_element("d",set["b","a","c","a"]) [↵] 0 => false



Thanks

parisse
Messages : 5740
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: SET functions

Message par parisse » lun. déc. 17, 2018 8:44 pm

It's more precise to have the position and it's the same for testing.

Répondre