HP Forums

Full Version: Set theory on HP Prime
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,
Does the prime have any facilities for dealing with sets such as union, difference, equality and such?
for example in PSUDOCODE:

{1, 2, 3} Union {2, 4, 5} = {1, 2, 3, 4, 5}
{1, 2, 3} Intersection {2, 4, 5} = {2}
{1, 2, 3} == {2, 1, 3} == TRUE
...
Reading the Xcas documentation here and there is a full section on sets - tried using a similar syntax but the prime doesn't know what I'm on about. >;|
Sets are supported: the infix operators are union, minus, intersect, and you should use set[ ] instead of {} or [ ] to avoid confusion with lists/vectors, e.g. for ==
set[1,2]==set[2,1]
[1,2]==[2,1]
Thanks for the reply Parisse
I just tried evaluating the following in the home screen

set[1,2]==set[2,1] ... result 1
set[1,2]==set[2,1,5] ... result 1 // WTF?

am I not understanding set theory correctly?

also every time set[..] gets evaluated it turns into set(..)
and 'set(1,2) union set(2, 1, 5)' gives a syntax error... is there any documentation?
Just tried on my emulator, set[1,2]==set[2,1,5] correctly returns 0 here and set[] are not converted to set(), so perhaps this is a UI bug that has been fixed.
(05-07-2014 06:57 AM)parisse Wrote: [ -> ]Sets are supported: the infix operators are union, minus, intersect, and you should use set[ ] instead of {} or [ ] to avoid confusion with lists/vectors, e.g. for ==
set[1,2]==set[2,1]
[1,2]==[2,1]

Good to know! By the way, minus and union don't seem to appear in the toolbox catalog (intersect is in there, though).
I have also tried out the commands mentioned by Parisse and they work correctly in CAS, but result in syntax error in Home.

A.
Thanks guys - so I ran it under the CAS screen and can now confirm that set[1 2]==set[2 1 5] does indeed evaluate to zero... yey I don't have to learn a new formulation of set theory Smile

{ just to be clear though it's definately still mutzed under the home screen as of the current firmware running on a physical device - I had no idea the calculators split brain disorder ran so deep!}
(05-07-2014 03:43 PM)Helge Gabert Wrote: [ -> ]
(05-07-2014 06:57 AM)parisse Wrote: [ -> ]Sets are supported: the infix operators are union, minus, intersect, and you should use set[ ] instead of {} or [ ] to avoid confusion with lists/vectors, e.g. for ==
set[1,2]==set[2,1]
[1,2]==[2,1]

Good to know! By the way, minus and union don't seem to appear in the toolbox catalog (intersect is in there, though).

There are the standard math symbols for union and intersection in the Chars list, but they do not work as such.
The HP Prime never ceases to tease me. In CAS, if I type
[1,2,3] union [2,5]
in the command line, it displays (correctly)
union( [1,2,3], [2,5]) [1,2,3,5]

But if I enter directly
union( [1,2,3], [2,5])
in the command line, it reports syntax error.
This is a textbook mode display bug, if you uncheck it in Settings, it's ok.
Reference URL's