Intersection is a term that relates to descriptive geometry and functions. Intersections are points which are included in multiple objects. They are intersections of the object they belong to.
Questions tagged [intersection]
2483 questions
1435
votes
57 answers
Removing duplicates in lists
How can I check if a list has any duplicates and return a new list without duplicates?

Neemaximo
- 20,031
- 12
- 32
- 40
1001
votes
40 answers
Simplest code for array intersection in javascript
What's the simplest, library-free code for implementing array intersections in javascript? I want to write
intersection([1,2,3], [2,3,4,5])
and get
[2, 3]

Peter
- 127,331
- 53
- 180
- 211
477
votes
21 answers
Find intersection of two nested lists?
I know how to get an intersection of two flat lists:
b1 = [1,2,3,4,5,9,11,15]
b2 = [4,5,6,7,8]
b3 = [val for val in b1 if val in b2]
or
def intersect(a, b):
return list(set(a) & set(b))
print intersect(b1, b2)
But when I have to find…

elfuego1
- 10,318
- 9
- 28
- 24
424
votes
17 answers
How to find list intersection?
a = [1,2,3,4,5]
b = [1,3,5,6]
c = a and b
print c
actual output: [1,3,5,6]
expected output: [1,3,5]
How can we achieve a boolean AND operation (list intersection) on two lists?

csguy11
- 5,007
- 6
- 22
- 20
288
votes
2 answers
How to calculate the intersection of two sets?
Possible Duplicate:
Efficiently finding the intersection of a variable number of sets of strings
Say, have two Hashset, how to calculate the intersection of them?
Set s1 = new HashSet();
Set s2 = new…

user496949
- 83,087
- 147
- 309
- 426
197
votes
3 answers
How can I get the intersection, union, and subset of arrays in Ruby?
I want to create different methods for a class called Multiset.
I have all the required methods, but I'm unsure of how to write intersection, union, and subset methods.
For intersection and union, my code starts like this:
def intersect(var)
x =…

user487743
- 2,145
- 4
- 16
- 11
195
votes
9 answers
Test if lists share any items in python
I want to check if any of the items in one list are present in another list. I can do it simply with the code below, but I suspect there might be a library function to do this. If not, is there a more pythonic method of achieving the same result. …

fmark
- 57,259
- 27
- 100
- 107
164
votes
24 answers
Intersection and union of ArrayLists in Java
Are there any methods to do so? I was looking but couldn't find any.
Another question: I need these methods so I can filter files.
Some are AND filters and some are OR filters (like in set theory), so I need to filter according to all files and the…

yotamoo
- 5,334
- 13
- 49
- 61
111
votes
2 answers
Difference between extending and intersecting interfaces in TypeScript?
Let's say the following type is defined:
interface Shape {
color: string;
}
Now, consider the following ways to add additional properties to this type:
Extension
interface Square extends Shape {
sideLength: number;
}
Intersection
type Square =…

Willem-Aart
- 2,200
- 2
- 19
- 27
102
votes
10 answers
Intersecting two dictionaries
I am working on a search program over an inverted index. The index itself is a dictionary whose keys are terms and whose values are themselves dictionaries of short documents, with ID numbers as keys and their text content as values.
To perform an…

norman
- 5,128
- 13
- 44
- 75
94
votes
6 answers
Python -Intersection of multiple lists?
I am playing with python and am able to get the intersection of two lists:
result = set(a).intersection(b)
Now if d is a list containing a and b and a third element c, is there an built-in function for finding the intersection of all the three…

Legend
- 113,822
- 119
- 272
- 400
92
votes
6 answers
Finding the intersection between two series in Pandas
I have two series s1 and s2 in pandas and want to compute the intersection i.e. where all of the values of the series are common.
How would I use the concat function to do this? I have been trying to work it out but have been unable to (I don't want…

user7289
- 32,560
- 28
- 71
- 88
81
votes
9 answers
Efficient intersection of two List in Java?
Question is simple:
I have two List
List columnsOld = DBUtils.GetColumns(db, TableName);
List columnsNew = DBUtils.GetColumns(db, TableName);
And I need to get the intersection of these. Is there a quick way to achieve this?

Pentium10
- 204,586
- 122
- 423
- 502
76
votes
4 answers
Intersect Two Lists in C#
I have two lists:
List data1 = new List {1,2,3,4,5};
List data2 = new List{"6","3"};
I want do to something like
var newData = data1.intersect(data2, lambda expression);
The lambda expression should return true if…

Merni
- 2,842
- 5
- 36
- 42
70
votes
5 answers
Circle-circle intersection points
How do I calculate the intersection points of two circles. I would expect there to be either two, one or no intersection points in all cases.
I have the x and y coordinates of the centre-point, and the radius for each circle.
An answer in python…

fmark
- 57,259
- 27
- 100
- 107