This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
00:04 Manifest0 left 02:27 jgaz left 04:04 deoac joined 05:05 sivoais left 05:14 sivoais joined 05:34 teatime joined 08:22 Manifest0 joined
rcmlz Thanks for your thoughts, I now understand that @array.&my-function is much easier than attaching my-function via role - especially when doing recursive algorithms - onto the object directly. My original code (which I put on rosetta - because parallel implementation was mentioned but never shown) looks like: #| Recursive, parallel-batch-tuned, single-pass, quicksort implementation sub quicksort-parallel(@a, 09:12
$batch) { return @a if @a.elems < 2; # separate unsorted input into Order Less, Same and More compared to a random $pivot my $pivot = @a.pick; my %prt{Order} is default([]) = @a.classify( * cmp $pivot ); # decide if we sort the Less partition on a new thread my $less = %prt{Less}.elems >= $batch ?? start { samewith(%prt{Less}, $batch) } !! samewith(%prt{Less},
$batch); # meanwhile use current thread for sorting the More partition my $more = samewith(%prt{More}, $batch); # if we went parallel, we need to await the result await $less andthen $less = $less.result if $less ~~ Promise; # concat all sorted partitions into a list and return |$less, |%prt{Same}, |$more; } my @test = 1,2,4,6,3; say @test.&quicksort-parallel(2**16);
Using a named parameter in my Role-attaching-attempts was just a trial and error, nothing realy needed. 09:14
Having said that, I now realize that using a named parameter is better - as it serves as documentation. 09:15
The same code using samewith instead of quicksort-parallel works also when refactoring return @a if @a.elems < 2; into a multi. However, using samewith refactors out the actual function name - and I will try if it helps pupils to understand Recursion initially better. 09:22
ab5tract_ rcmlz++ 09:40
11:39 teatwo joined 11:41 teatime left 14:24 lucs left, lucs joined 15:36 Util left 15:38 Util joined 16:00 guifa left 16:01 guifa joined 16:49 deoac left 17:05 deoac joined 17:08 deoac left 17:35 teatwo left 17:39 teatime joined 23:38 teatime left 23:39 teatwo joined