2 list intersection

image

list a = 1,2,3
list b = 3,4,5

How i can found 3 ? (without the < for each > block)

One method

image

Thank you,

I decided to try and do other operations and I came up with these (just in case someone else wants/needs them)

ProjectName=listLogical

Your OR, AND, and XOR list operations are brilliant; thanks for sharing them, Simon!

something append when the list contains duplicates:not the same result if i reverse the list...
image
image

You can use the remove duplicates reporter from the list utilities library if you want that behaviour

image

Edit - had a look inside remove duplicates from reporter and it's simple to do without importing the library

image

This is all terrific, but I have a nit to pick about the terminology. "And," "or," etc. are Boolean operators, whose domain and range are Booleans (True and False). All the functions in this thread are set operators, so they should be called intersection and union respectively. (I don't know a name for the set operation analogous to xor, though. The typical third set operator is set difference, A−(A⋂B), the elements of A not also in B. So I guess your xor operation would be represented in set theory as
(A−B) ⋃ (B−A).

the first version is ok for my project but:

image

list a = 1,2,3,3
list b = 3,3,4,5

should the result be 3 or 33?

Sets have unique, unordered members. These lists are not sets and the function is not a set operation. So there is no proper way, and function can be defined as you like.

I understand...

As I said earlier, the first version is compatible with my project, it was just a question I was wondering ...

In my project, I have about 500 clones on a 2000 x 2000 map and I want to send messages to < my neighbors > but only those that are clones of a particular sprite.

In this specific case, < my neighbors > can be considered as a set, < my clones > can be considered as a set: so no problem ...

Thank you @cymplecy for your time

(Hope google translate did a good job!)

In that case, don't use a general-purpose set intersection. The whole point of MY NEIGHBORS is that it reports a small set of sprites for further filtering. You defeat that purpose if you also generate MY CLONES and traverse both lists. Just do
KEEP <is this my clone?> FROM (MY NEIGHBORS)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.