함수 intersection

(Intersection에서 넘어옴)
intersection

1 PHP[ | ]

$arr1 = array('A', 'B', 'C', 'D');
$arr2 = array('C', 'D', 'E', 'F');
print_r( array_values(array_intersect($arr1, $arr2)) );
// Array ( [0] => C [1] => D )

2 Python[ | ]

set1 = {'A', 'B', 'C', 'D'}
set2 = {'C', 'D', 'E', 'F'}
print( set1 & set2 )
# {'C', 'D'}
print( set1.intersection (set2) )
# {'C', 'D'}

3 Perl[ | ]

use Array::Utils qw(:all);
my @arr1= ('A', 'B', 'C', 'D');
my @arr2 = ('C', 'D', 'E', 'F');
print intersect(@arr1, @arr2);

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}