June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
27
Task/Hash-join/Perl-6/hash-join.pl6
Normal file
27
Task/Hash-join/Perl-6/hash-join.pl6
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
sub hash-join(@a, &a, @b, &b) {
|
||||
my %hash := @b.classify(&b);
|
||||
|
||||
@a.map: -> $a {
|
||||
|(%hash{a $a} // next).map: -> $b { [$a, $b] }
|
||||
}
|
||||
}
|
||||
|
||||
# Testing:
|
||||
|
||||
my @A =
|
||||
[27, "Jonah"],
|
||||
[18, "Alan"],
|
||||
[28, "Glory"],
|
||||
[18, "Popeye"],
|
||||
[28, "Alan"],
|
||||
;
|
||||
|
||||
my @B =
|
||||
["Jonah", "Whales"],
|
||||
["Jonah", "Spiders"],
|
||||
["Alan", "Ghosts"],
|
||||
["Alan", "Zombies"],
|
||||
["Glory", "Buffy"],
|
||||
;
|
||||
|
||||
.say for hash-join @A, *[1], @B, *[0];
|
||||
Loading…
Add table
Add a link
Reference in a new issue