Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,19 @@
|
|||
# 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);
|
||||
}
|
||||
|
||||
my @list = 2,1,3,5;
|
||||
say beadsort(@list).perl;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
sub beadsort(*@list) {
|
||||
my @rods;
|
||||
for words ^«@list -> $x { @rods[$x].push(1) }
|
||||
gather for ^@rods[0] -> $y {
|
||||
take [+] @rods.map: { .[$y] // last }
|
||||
}
|
||||
}
|
||||
|
||||
say beadsort 2,1,3,5;
|
||||
Loading…
Add table
Add a link
Reference in a new issue