Help for this page

Select Code to Download


  1. or download this
    my @A = (1,2,3,4,5,4,3,2,1,2);
    my @B = (2,4,6,8,10,8,6,4,2);
    ...
    for (sort keys %Pairs){
      print "$_:\n", map("  $_\n", map(join('-', @$_), @{ $Pairs{$_} })), 
    +"\n";
    }
    
  2. or download this
    push @{ $First{  $A[$_] } }, $_ for (0..$#A);
    push @{ $Second{ $B[$_] } }, $_ for (0..$#B);
    
  3. or download this
      for my $Common (grep {exists $Second{$_}} keys %First){
    
  4. or download this
      for my $Idx (@{ $First{$Common} }){
        push @{ $Pairs{$Common} }, map([$Idx, $_], @{ $Second{$Common} });
      }
    
  5. or download this
      $Pairs{Each Common Value} = [ [A1, B1], [A1, B2], [A2, B1], [A2, B2]
    + ]
    
  6. or download this
      $Pairs{4} = [[3,1], [3,7], [5,1], [5,7]]
    
  7. or download this
    2:
      1-0
    ...
      3-7
      5-1
      5-7