Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,11 @@
|
|||
sub selection_sort ( @a is copy ) {
|
||||
for 0 ..^ @a.end -> $i {
|
||||
my $min = [ $i+1 .. @a.end ].min: { @a[$_] };
|
||||
@a[$i, $min] = @a[$min, $i] if @a[$i] > @a[$min];
|
||||
}
|
||||
return @a;
|
||||
}
|
||||
|
||||
my @data = 22, 7, 2, -5, 8, 4;
|
||||
say 'input = ' ~ @data;
|
||||
say 'output = ' ~ @data.&selection_sort;
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
sub selectionSort(@tmp) {
|
||||
for ^@tmp -> $i {
|
||||
my $min = $i; @tmp[$i, $_] = @tmp[$_, $i] if @tmp[$min] > @tmp[$_] for $i^..^@tmp;
|
||||
}
|
||||
return @tmp;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue