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:00 cleo left, hexology left, KOTP left, destroycomputers left, snonux left, MasterDuke left, jgaz left, lizmat left, snonux joined, elcaro left, SmokeMachine left, elcaro joined, SmokeMachine joined 00:02 lizmat joined 00:04 KOTP joined 00:07 hexology joined, destroycomputers joined 00:12 jgaz joined 00:47 hythm joined 00:59 deoac joined 01:38 deoac left 03:16 MasterDuke joined 05:29 hythm left 05:45 jgaz left 05:46 jgaz joined 05:57 MasterDuke left 06:20 cleo joined 07:00 siavash joined 07:37 siavash left 08:13 dakkar joined 09:11 Manifest0 joined 10:28 famra joined 10:29 famra left, famra joined 16:37 dakkar left
rcmlz I would like to implement the Quick-Sort-Algorithm using partitions less/same/more as stated on wikipedia - and doing like promised on www.rosettacode.org/wiki/Sorting_a...ksort#Raku in PARALLEL - idealy using simple hyper.map(): I have got that far multi qsort-recursiv(()) { () } multi qsort-recursiv(@input){ my $pivot = @input.pick; @input.classify( -> $element { $element cmp 18:49
$pivot }, :into( my %partition{Order} ) ); flat callwith(%partition{Less}), %partition{Same}, callwith(%partition{More}) } (complete source incl. tests here: gist.github.com/rcmlz/552726f93e01...59947901b) but can not get my head around how to apply map() to %partitions correctly. Is there a way to make it show off style such that it is worth maybe update rosetta code
and add such a impressively short and handsome, parallel version?
Idealy the source code should read like a sentence "First classify the elements of the input list by comparing all of them to a randomly choosen pivot element and then recursivly call the same function in parallel on the Less and More partition and finaly combine everything together into a sorted output." 18:58
Any hints? 18:59
19:48 ab5tract left
Manifest0 How do i zip all the lists that are inside of a list? the call "zip |@list" doesnt work. 20:37
nemokosch can you show the context in which in doesn't work? 20:39
for example, if it's a nested array, I would guess that it won't work 20:40
Manifest0 my @a = ([1,2,3], [4,5,6], [7,8,9]); zip |@a 20:41
nemokosch yeah... that's a nested array. let me try something 20:42
m: my @a := ([1,2,3], [4,5,6], [7,8,9]); zip |@a
Raku eval WARNINGS for /home/glot/main.raku: Useless use of "zip |@a" in expression "zip |@a" in sink context (line 1)
nemokosch right, maybe printing it would help
m: my @a := ([1,2,3], [4,5,6], [7,8,9]); say zip |@a 20:43
Raku eval ((1 4 7) (2 5 8) (3 6 9))
nemokosch I wouldn't be surprised if this even worked without the slip
m: my @a := ([1,2,3], [4,5,6], [7,8,9]); say zip @a
Raku eval ((1 4 7) (2 5 8) (3 6 9))
nemokosch dang
lakmatiol > [Z] (<1 2 3>, <4 5 6>, <7 8 9>) ((1 4 7) (2 5 8) (3 6 9)) using [Z] should also work
Manifest0 "[Z] @a" works :-) 20:44
nemokosch I think at some point zip and [Z] call one another
it's worrying if [Z] works on the same thing zip doesn't work on 20:45
m: my @a = ([1,2,3], [4,5,6], [7,8,9]); say [Z] @a; say zip @a 20:46
Raku eval ((1 4 7) (2 5 8) (3 6 9)) (([1 2 3] [4 5 6] [7 8 9]))
Manifest0 they have different behaviours
nemokosch as you can see, it dropped the containers
I don't like this itemization but two wrongs don't make a right. They should work the same way. 20:47
github.com/rakudo/rakudo/issues/5247 20:49
Manifest0 nemokosch, lakmatiol thanks for the help 20:51
codesections @rcmlz Does this do what you want? multi qsort-recursiv([]) { () } multi qsort-recursiv(@input){ my $pivot = @input.pick; my %partition = :Less[], :Same[], :More[]; @input.hyper.map: -> $element { %partition{$element cmp $pivot}.push: $element }; flat samewith(%partition{Less}), |%partition{Same}, 21:33
samewith(%partition{More}); }
21:35 Heptite joined
gfldex @rclmz here is a version that is quite recursive: gist.github.com/gfldex/39e164aa463...854ab3c6ef 22:37
23:24 camelia left 23:45 camelia joined