Anonymous user
Sorting algorithms/Quicksort: Difference between revisions
→{{header|Raku}}
imported>Rcmlz |
imported>Rcmlz |
||
Line 8,241:
flat quicksort($before), $pivot, $equiv, quicksort($after)
}</syntaxhighlight>
Note that <code>$before</code> and <code>$after</code> are bound to lazy lists
<syntaxhighlight lang="raku" line>
#|« Recursive,
* in partitioning/classifying step by .race or .hyper
* in
»
sub quicksort-recursive-parallel(@input) {
Line 8,258 ⟶ 8,257:
my %partiton = $_;
my $less = start { %partiton{Less}:exists ?? samewith(%partiton{Less}) !! [] };
my $more =
await $less andthen |$less.result, |%partiton{Same}, |$more
}
}
#=« Implementation
* samewith() refactors out the actual name of the routine.
* andthen passes
* no need to start a new thread for More partition - as we better use current thread.
»
</syntaxhighlight>
|