Nasıl bu perl yordam bir PHP fonksiyonu haline çevirmek?
sub disagreement {
my $disagreement = 0;
my %aggregate = () ;
foreach my $item (@_) {$aggregate{$item}++}
foreach my $cat_a (keys %aggregate) {
foreach my $cat_b (keys %aggregate) {
if ($cat_a != $cat_b) {$disagreement += $aggregate{$cat_a} * $aggregate{$cat_b} * &$distance_metric ($cat_a , $cat_b)}
}
}
$disagreement /= @_ * (@_ - 1) ;
return ($disagreement) ;
}
Burada bir sorun var:
foreach my $cat_a (keys %aggregate) {
foreach my $cat_b (keys %aggregate) {
}
}