As I've never got into L:  ,  I found these versions which can manage without:

   every
&>
   each
&.>
   -:every/~ A;B;<C
1 0 0
0 1 1
0 1 1
   -.each/~ A;B;<;:'x y z w' NB. more interesting!
+-----+---++
|     |   ||
+-----+---++
|+-+  |   ||
||z|  |   ||
|+-+  |   ||
+-----+---++
|+-+-+|+-+||
||z|w|||w|||
|+-+-+|+-+||
+-----+---++
   -.each/L: 2 CP ~ A;B;<;:'x y z w'
+-------+-----+--+
|++     |++   |++|
|||     |||   ||||
|++     |++   |++|
+-------+-----+--+
|+---+  |++   |++|
||+-+|  |||   ||||
|||z||  |++   |++|
||+-+|  |     |  |
|+---+  |     |  |
+-------+-----+--+
|+-----+|+---+|++|
||+-+-+|||+-+|||||
|||z|w|||||w|||++|
||+-+-+|||+-+||  |
|+-----+|+---+|  |
+-------+-----+--+
   <@-.each/~ A;B;<;:'x y z w' NB. to get same nesting
+-------+-----+--+
|++     |++   |++|
|||     |||   ||||
|++     |++   |++|
+-------+-----+--+
|+---+  |++   |++|
||+-+|  |||   ||||
|||z||  |++   |++|
||+-+|  |     |  |
|+---+  |     |  |
+-------+-----+--+
|+-----+|+---+|++|
||+-+-+|||+-+|||||
|||z|w|||||w|||++|
||+-+-+|||+-+||  |
|+-----+|+---+|  |
+-------+-----+--+


   ts'-.each/L: 2 CP ~ A;B;<;:''x y z w'''NB. time & space
2.28e_5 8448
   ts'-.each/~ A;B;<;:''x y z w'''NB. slightly less space
2.2e_5 5952

   ts'<@-.each/~ A;B;<;:''x y z w'''
1.6e_5 6592

Space more significant than time for such a small example!

Cheers,

Mike




On 13/05/2020 18:20, Lippu Esa wrote:
Thank you Henry for the solution, also for the sort tip! This particular case 
had three sets with less than 40 members.

Actually I was checking for primary key existence differences in three SQL 
database environments. An ETL consultant complained about slow network 
performance but it turned out to be eight missing primary keys in one 
environment. The strange thing is that the performance was there for a long 
time and the growth of the tables was modest. However, this day was different.

Esa
-----Original Message-----
From: Programming <[email protected]> On Behalf Of Henry 
Rich
Sent: Wednesday, May 13, 2020 6:40 PM
To: [email protected]
Subject: Re: [Jprogramming] minusdot problem with sets

look at

-.&>/ L: 2 CP~ A;B;<C

(dissect might help).

Also consider sorting before comparison if you have many items.

Henry Rich


On 5/13/2020 11:10 AM, Lippu Esa wrote:
Hi Everybody!

I need to compare 3-4 sets (boxed lists of literals) for set membership 
differences. This makes 3 pairwise comparisons with 3 sets and six comparisons 
with four set.

It would be nice to be able to use Cartesian product to make a nxn table for 
visual reasons (in my case the differences should be small).

I managed to be able to do set comparison with CP but I am having trouble with 
minusdot operator -. .

A simple example below.

Any ideas would be greatly appreciated.


Esa


     NB. 3 sets, A is missing member z that is in sets B and C that are 
identical
     ]A=.;:'x y'
+-+-+
|x|y|
+-+-+
     ]B=.;:'x y z'
+-+-+-+
|x|y|z|
+-+-+-+
     ]C=.;:'x y z'
+-+-+-+
|x|y|z|
+-+-+-+

     NB. differences in sets pairwise
     A(-.;-.~)B
++-+
||z|
++-+
     A(-.;-.~)C
++-+
||z|
++-+
     B(-.;-.~)C
+++
|||
+++

     NB.Cartesian product
     CP
+-+-+-------+
|{|@|+-+-+-+|
| | ||,|&|<||
| | |+-+-+-+|
+-+-+-------+
     -:/ L: 2 CP~ A;B;<C NB. set equality, this works
+-+-+-+
|1|0|0|
+-+-+-+
|0|1|1|
+-+-+-+
|0|1|1|
+-+-+-+
     -./ L: 2 CP~ A;B;<C NB. differences in sets, this doesn't work
+---------+-------+-------+
|         |+-----+|+-----+|
|         ||+-+-+|||+-+-+||
|         |||x|y|||||x|y|||
|         ||+-+-+|||+-+-+||
|         |+-----+|+-----+|
+---------+-------+-------+
|+-------+|       |       |
||+-+-+-+||       |       |
|||x|y|z|||       |       |
||+-+-+-+||       |       |
|+-------+|       |       |
+---------+-------+-------+
|+-------+|       |       |
||+-+-+-+||       |       |
|||x|y|z|||       |       |
||+-+-+-+||       |       |
|+-------+|       |       |
+---------+-------+-------+


Tämän viestin sisältö liitteineen on luottamuksellinen ja tarkoitettu vain sen 
vastaanottajalle. Jos et ole viestin tarkoitettu vastaanottaja, pyydämme sinua 
poistamaan viestin liitteineen ja sen jälkeen ilmoittamaan asiasta välittömästi 
viestin lähettäjälle. Viestin sisällön paljastaminen, kopioiminen tai muu 
käyttö on kielletty.

The contents of this message and any attachments are confidential and meant 
solely for the intended recipient. If you are not the intended recipient, we 
kindly ask that you delete the message and its attachments, and immediately 
notify the sender of the email. Disclosing, copying or using the contents of 
the message is strictly prohibited.
----------------------------------------------------------------------
For information about J forums see 
https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&amp;data=01%7C01%7C%7Cd69d6868237945e37ac708d7f753f728%7C5090e269dbea4e98a9aa3e70be5890f7%7C0&amp;sdata=lMvd4GbxTI2e%2B2vojvNxjw%2F0kkZsGqD2r20XCMcTUFQ%3D&amp;reserved=0

--
This email has been checked for viruses by AVG.
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.avg.com%2F&amp;data=01%7C01%7C%7Cd69d6868237945e37ac708d7f753f728%7C5090e269dbea4e98a9aa3e70be5890f7%7C0&amp;sdata=jguvLVtZlTUExNckS%2Fp6sScrbZ8jCFP9LTNtYn3yVBw%3D&amp;reserved=0

----------------------------------------------------------------------
For information about J forums see 
https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&amp;data=01%7C01%7C%7Cd69d6868237945e37ac708d7f753f728%7C5090e269dbea4e98a9aa3e70be5890f7%7C0&amp;sdata=lMvd4GbxTI2e%2B2vojvNxjw%2F0kkZsGqD2r20XCMcTUFQ%3D&amp;reserved=0

Tämän viestin sisältö liitteineen on luottamuksellinen ja tarkoitettu vain sen 
vastaanottajalle. Jos et ole viestin tarkoitettu vastaanottaja, pyydämme sinua 
poistamaan viestin liitteineen ja sen jälkeen ilmoittamaan asiasta välittömästi 
viestin lähettäjälle. Viestin sisällön paljastaminen, kopioiminen tai muu 
käyttö on kielletty.

The contents of this message and any attachments are confidential and meant 
solely for the intended recipient. If you are not the intended recipient, we 
kindly ask that you delete the message and its attachments, and immediately 
notify the sender of the email. Disclosing, copying or using the contents of 
the message is strictly prohibited.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to