]> git.vpit.fr Git - perl/modules/Sub-Nary.git/blobdiff - lib/Sub/Nary.pm
Rewrite combine in XS
[perl/modules/Sub-Nary.git] / lib / Sub / Nary.pm
index bda8335f47b95803c87f56b0308866ea011f02cc..f21c8f81446aa64aff112b2f49f22bfb7fa47939 100644 (file)
@@ -184,27 +184,6 @@ sub scale {
  return (ref $r) ? { map { $_ => $r->{$_} * $c } keys %$r } : { $r => $c };
 }
 
-sub combine {
- reduce {{
-  my %res;
-  my $la = delete $a->{list};
-  my $lb = delete $b->{list};
-  if (defined $la || defined $lb) {
-   $la ||= 0;
-   $lb ||= 0;
-   $res{list} = $la + $lb - $la * $lb;
-  }
-  while (my ($ka, $va) = each %$a) {
-   $ka = int $ka;
-   while (my ($kb, $vb) = each %$b) {
-    my $key = $ka + int $kb;
-    $res{$key} += $va * $vb;
-   }
-  }
-  \%res
- }} map { (ref) ? $_ : { $_ => 1 } } grep defined, @_;
-}
-
 sub power {
  my ($p, $n, $c) = @_;
  return unless defined $p;