HP Forums
INTERSECT ? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: INTERSECT ? (/thread-7115.html)



INTERSECT ? - Tyann - 10-28-2016 03:26 PM

Bonjour

INTERSECT({1,2,3,2},{0,2,3,2}) -> {2,3,2} OK 2 est répété dans chaque liste.
INTERSECT({1,2,3,2},{0,2,3,0}) -> {2,3,2} est-ce normal ? j'attendais {2,3}
INTERSECT({1,2,3,4},{2,2,3,0}) -> {2,3} OK pour moi
INTERSECT({2,2,3,0},{1,2,3,4}) -> {2,3,2} ce sont les mêmes listes ?

Merci d'avance

Hello

INTERSECT ({1,2,3,2}, {0,2,3,2}) -> {2,3,2} OK 2 is repeated in each list.
INTERSECT ({1,2,3,2}, {0,2,3,0}) -> {2,3,2} is this normal? I expected {2,3}
INTERSECT ({1,2,3,4}, {2,2,3,0}) -> {2,3} OK for me
INTERSECT ({2,2,3,0}, {1,2,3,4}) -> {2,3,2} are the same lists?

thank you in advance


RE: INTERSECT ? - compsystems - 10-28-2016 03:45 PM

Wolfram all returns set{2,3}
https://www.wolframalpha.com/input/?i=INTERSECT(%5B1,2,3,2%5D,%5B0,2,3,2%5D)

in CAS MODE

INTERSECT(set[1,2,3,2],set[0,2,3,2]) -> [2,3] [up] [copy] -> set[2,3] // ok

-----------------------------------¬
I take this publication to make the new request, and do not a new publication =)
I would like to see in history view in pretty print
INTERSECT(set[1,2,3,2],set[0,2,3,2]) -> [1, 2, 3, 2] ∩ [0, 2, 3, 2]
or at least infix notation -> [1, 2, 3, 2] intersection [0, 2, 3, 2]
and 2-D templates for sets commands [∩] [∪] ...
------------------------------------

INTERSECT(set[1,2,3,2],set[0,2,3,0]) -> set[2,3] // ok
INTERSECT(set[1,2,3,4],set[2,2,3,0]) -> set[2,3] // ok
INTERSECT(set[2,2,3,0],set[1,2,3,4]) -> set[2,3] // ok
INTERSECT([1,2,3,2],[0,2,3,2]) -> {} ?
INTERSECT({1,2,3,2},{0,2,3,2}) -> {2,3,2}?

in HOME Mode

INTERSECT(set[1,2,3,2],set[0,2,3,2]) -> {2} ?
INTERSECT([1,2,3,2],[0,2,3,2]) -> {} ?
INTERSECT({1,2,3,2},{0,2,3,2}) -> {2,3,2} ?

Without complete documentation I can not determine how the calculator works =(


RE: INTERSECT ? - compsystems - 10-28-2016 08:00 PM

we need the complete documentation of operation of cas and hp-prime, I do not understand really know when to put brackets [] or lists {} on a cmd or function


RE: INTERSECT ? - parisse - 10-29-2016 06:24 AM

The CAS command for set intersection is intersect (lowercase) and is infixed, not prefixed.
[1,2,3,2] intersect [0,2,3,2] -> set[2,3]
There is no duplicate with intersect.
The history displays intersect incorrectly prefixed in 2d mode, but correctly in algebraic mode.


RE: INTERSECT ? - Tyann - 11-01-2016 04:35 PM

Bonjour
Merci à tous pour vos réponses.
Le but étant d'adapter ces fonctions (INTERSECT,DIFFERENCE et UNION)
à d'autres machines, je vais faire sans répétitions.
D'ailleurs sur la prime, UNION qui supprime tous les doublons
fonctionne avec une seule liste et peut
donc corriger INTERSECT.

Hello
Thank you all for your answers.
The goal is to adapt these functions (INTERSECT, DIFFERENCE and UNION)
to other machines, I'll do without repetitions.
Besides on the prime, UNION removes all duplicates
works with only one list and can
therefore correct INTERSECT.


RE: INTERSECT ? - Tim Wessman - 11-02-2016 02:12 PM

One of the challenges that we faced with these commands was trying to determine if they should follow the "mathematical definition" or the "programming definition". What I mean by this is that the purely mathematical definition operates exclusively on sets - groups with no duplicates. However, in actual usage there are tons of cases where you actually DO want to keep duplicates and not be suppressing them all. Having the pure set based version means that in probably the majority of cases a user would like to use it in a program, they end up having to rewrite it to get the desired behavior.

The compromise we decided to make was that if you do want to suppress duplicates, the UNION command would do so as has been pointed out.


RE: INTERSECT ? - Tyann - 11-03-2016 05:34 AM

Bonjour
Merci pour ces précisions Tim.

Hello
Tim thank you for these details.


RE: INTERSECT ? - compsystems - 11-03-2016 11:01 AM

(10-29-2016 06:24 AM)parisse Wrote:  The CAS command for set intersection is intersect (lowercase) and is infixed, not prefixed.
[1,2,3,2] intersect [0,2,3,2] -> set[2,3]
There is no duplicate with intersect.
The history displays intersect incorrectly prefixed in 2d mode, but correctly in algebraic mode.

Details that are leaving overlook. Also to avoid misunderstandings the history-view on CAS mode must be different than in HOME mode, using real symbols of sets, I think it is not difficult to implement, as they see are many hours of coding, but a more precise mathematical system