2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,4 +1,15 @@
|
|||
use List::Utils;
|
||||
# routine cribbed from List::Utils;
|
||||
sub transpose(@list is copy) {
|
||||
gather {
|
||||
while @list {
|
||||
my @heads;
|
||||
if @list[0] !~~ Positional { @heads = @list.shift; }
|
||||
else { @heads = @list.map({$_.shift unless $_ ~~ []}); }
|
||||
@list = @list.map({$_ unless $_ ~~ []});
|
||||
take [@heads];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub beadsort(@l) {
|
||||
(transpose(transpose(map {[1 xx $_]}, @l))).map(*.elems);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
sub beadsort(*@list) {
|
||||
my @rods;
|
||||
for ^«@list -> $x { @rods[$x].push(1) }
|
||||
for words ^«@list -> $x { @rods[$x].push(1) }
|
||||
gather for ^@rods[0] -> $y {
|
||||
take [+] @rods.map: { .[$y] // last }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue