본문 바로가기

Perl

[Perl] Set의 구현

조금 찾아보니
CPAN에 모듈이 있는 것 같기도 하고..
hash를 사용해 구현하기도 하는 듯...
 
@set_list=();
%divisors_hash=();
unless(exists ($divisors_hash{$_})) {
$divisors_hash{$_}=1; #key가 set의 원소가 됨
}
foreach (keys %divisors_hash) {
push @set_list, $_;
}
view raw set.pl hosted with ❤ by GitHub