Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 1x 1x 1x 2x 2x 2x 1x 1x 2x 6x 6x 4x 2x | import { purry } from './purry';
import { _reduceLazy, LazyResult } from './_reduceLazy';
/**
* Returns a list of elements that exist in both array.
* @param array the source array
* @param other the second array
* @signature
* R.intersection(array, other)
* @example
* R.intersection([1, 2, 3], [2, 3, 5]) // => [2, 3]
* @data_first
* @category Array
* @pipeable
*/
export function intersection<T>(source: T[], other: T[]): T[];
/**
* Returns a list of elements that exist in both array.
* @param array the source array
* @param other the second array
* @signature
* R.intersection(other)(array)
* @example
* R.intersection([2, 3, 5])([1, 2, 3]) // => [2, 3]
* @data_last
* @category Array
* @pipeable
*/
export function intersection<T>(other: T[]): (source: T[]) => T[];
export function intersection() {
return purry(_intersection, arguments, intersection.lazy);
}
function _intersection<T>(array: T[], other: T[]) {
const lazy = intersection.lazy(other);
return _reduceLazy(array, lazy);
}
export namespace intersection {
export function lazy<T>(other: T[]) {
return (value: T): LazyResult<T> => {
const set = new Set(other);
if (set.has(value)) {
return {
done: false,
hasNext: true,
next: value,
};
}
return {
done: false,
hasNext: false,
};
};
}
}
|