Creates the intersection of A and B.

@param Set $a
@param Set $b

@return Set
775209
public static function intersection(Set $a, Set $b) : Set
    {
        return new self(array_intersect($a->toArray(), $b->toArray()));
    }
662170
public function mul($a, $b)
    {
        return bcmul($this->bcNormalize($a), $this->bcNormalize($b));
    }
1361496
public function mul($a, $b)
    {
        $a = $this->convert($a);
        $b = $this->convert($b);
        switch ($this->arbitrate($a, $b)) {
            case 'int':
                return $this->calcEngine->intMul($a, $b);
            case 'float':
                return $this->calcEngine->floatMul($a, $b);
            case 'whole':
                return $this->calcEngine->wholeMul($a, $b);
            case 'natural':
                return $this->calcEngine->naturalMul($a, $b);
            case 'rational':
                return $this->calcEngine->rationalMul($a, $b);
            case 'complex':
                return $this->calcEngine->complexMul($a, $b);
            case 'complex:numeric':
                return $this->calcEngine->complexMul($a, $b->asComplex());
            case 'numeric:complex':
                return $this->calcEngine->complexMul($a->asComplex(), $b);
        }
    }
968591
public static function intersects(array $a, array $b): bool
    {
        $a = (array)$a;
        $b = (array)$b;

        return count(self::intersection($a, $b)) > 0;
    }
1327706
function(and, or) {
			var aIntersection = set.intersection(and, or.values[0]);
			var bIntersection = set.intersection(and, or.values[1]);
			if (!isOr(aIntersection) && !isOr(bIntersection)) {
				return set.union(aIntersection, bIntersection);
			}
			return new is.And([and, or]);
		}
605565
def intersection(self, other):
        
        #NOTE: This is a work around 
        # Python 3 return as the result of set.intersection a new set instance.
        # Python 2 however returns as a the result a ClusterShell.RangeSet.RangeSet instance.
        # ORIGINAL CODE: return self._wrap_set_op(set.intersection, other)
        copy = self.copy()
        copy.intersection_update(other)
        return copy
364213
public function similarity(&$A, &$B)
    {
        $a = array_fill_keys($A,1);
        $b = array_fill_keys($B,1);

        $intersect = count(array_intersect_key($a,$b));
        $union = count(array_fill_keys(array_merge($A,$B),1));

        return $intersect/$union;
    }
1058877
public function diff( \PhpSets\Set $set ) {
        $entries = $this->entries();
        $iterator = $set->entries();
        $intersect = new \PhpSets\Set;

        // check $set values
        while ( $entries->valid() ) {
            if ( ! $set->has( $entries->current() ) ) {
                $intersect->add( $entries->current() );
            }

            $entries->next();
        }

        // check $additionalSet values
        while ( $iterator->valid() ) {
            if ( ! $this->has( $iterator->current() ) ) {
                $intersect->add( $iterator->current() );
            }

            $iterator->next();
        }

        return $intersect;
    }
452886
function union(Set $that) {
        $union = $this->cloneEmpty();

        $this->for_each($this, [$union, 'add']);
        $this->for_each($that, [$union, 'add']);

        return $union;
    }
272406
public static function union(self $a, self $b): self
    {
        return new self(array_merge($a->toArray(), $b->toArray()));
    }
1302192
def intersection(other)
      if other.is_a?(AbsoluteSet) and other.universe.eql?(@universe)
        copy(:mask => @mask & other.mask)
      elsif other.is_a?(AbstractSet) and other.infinite?
        other.intersection(self)
      else
        copy(:mask => @mask & as_mask(other, false))
      end
    end
1345541
public static <T> Set<T> intersection(Collection<Set<T>> sets) {
		Set<T> result = new HashSet<>();
		if (sets.isEmpty()) {
			return result;
		}
		Iterator<Set<T>> iter = sets.iterator();
		result.addAll(iter.next());
		while (iter.hasNext()) {
			result.retainAll(iter.next());
		}
		return result;
	}
1051360
public static <E> Set<E> intersection(Set<E> s1, Set<E> s2) {
    Set<E> s = new HashSet<E>();
    s.addAll(s1);
    s.retainAll(s2);
    return s;
  }
10162
def intersect(a, b):
    
    if a[x0] == a[x1] or a[y0] == a[y1]:
        return False
    if b[x0] == b[x1] or b[y0] == b[y1]:
        return False
    return a[x0] <= b[x1] and b[x0] <= a[x1] and a[y0] <= b[y1] and b[y0] <= a[y1]
252775
public static <T> Set<T> intersection(Set<T>... sets) {
		return intersection(Arrays.asList(sets));
	}
1283023
def do_bb_intersect(a, b):
    """"""
    return a.p1.x <= b.p2.x \
        and a.p2.x >= b.p1.x \
        and a.p1.y <= b.p2.y \
        and a.p2.y >= b.p1.y
1092686
private function mergeValues($a, $b)
    {
        $x = array();
        $y = array();

        if (is_array($a)) {
            $x = $a;
        }

        foreach ($b as $key => $value) {
            $x[$key] = $value;
        }

        return $x;
    }