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. |
|||
01:07
jaguart joined
01:20
Manifest0 left
02:22
ACfromTX left
06:59
ACfromTX joined
08:29
teatime left
09:20
teatime joined
10:29
teatime left
10:30
teatime joined,
Manifest0 joined
11:00
teatime left,
teatime joined
|
|||
ab5tract | hey DarthGandalf, regarding using Array.splice to insert arrays, here is a workaround: | 11:22 | |
m: my @a = [1,1],[2,2],[3,3]; @a.splice(1,0,[[4,4],]); dd @a | 11:23 | ||
camelia | Mu @a = [[1, 1], [4, 4], [2, 2], [3, 3]] | ||
lizmat | m: my @a = [1,1],[2,2],[3,3]; @a.splice(1,0,$[4,4]); dd @a # just checkinng | 11:24 | |
camelia | Mu @a = [[1, 1], 4, 4, [2, 2], [3, 3]] | ||
lizmat | still feels like a bug to me | ||
but perhaps a bug that we cannot fix without breaking the ecosystem | 11:25 | ||
ab5tract | if so, it appears to be something in the way `@a.iterator.push-until-lazy` handles `$[]` | 11:26 | |
DarthGandalf shrugs | |||
I don't know what the right solution should be, sorry | |||
ab5tract | the workaround that I shared isn't going to go away, that's for sure | 11:28 | |
lizmat | true | 11:32 | |
librasteve | m: my @a = [1,1],[2,2],[3,3]; my @b = [4,4]; @a.splice(1,0,@b); say "@a" | 11:38 | |
Raku eval | @a | ||
librasteve | hmmm - discord doesn't like the at symbol --- I am just chiming in that splicing should handle where the insert is an array var | 11:40 | |
ab5tract | m: my @a = [1,1],[2,2],[3,3]; my @b = [4,4]; @a.splice(1,0,@b); dd @a | ||
camelia | Mu @a = [[1, 1], 4, 4, [2, 2], [3, 3]] | ||
librasteve | thanks! | ||
ab5tract | yup, it's the same issue | ||
lizmat | m: my @b = [4,4]; dd @b | 11:44 | |
camelia | Mu @b = [4, 4] | ||
lizmat | m: my @b = $[4,4]; dd @b | ||
camelia | Mu @b = [[4, 4],] | ||
lizmat | note itemization *is* taken into account then | 11:45 | |
and that [4,4] is flattened into @b is because of the single arg rule | |||
m: my @b = [4,4],[5,5]; dd @b | |||
camelia | Mu @b = [[4, 4], [5, 5]] | ||
ab5tract | y @a = [1,1],[2,2],[3,3]; my @b = $[4,4]; @a.splice(1,0,@b); dd @a | 11:47 | |
m: my @a = [1,1],[2,2],[3,3]; my @b = [4,4]; @a.splice(1,0,@b); dd @a | |||
camelia | Mu @a = [[1, 1], 4, 4, [2, 2], [3, 3]] | ||
ab5tract | dangit, sorry. | ||
m: my @a = [1,1],[2,2],[3,3]; my @b = [4,4]; @a.splice(1,0,@b); dd @a | |||
camelia | Mu @a = [[1, 1], 4, 4, [2, 2], [3, 3]] | ||
ab5tract | fat fingers today :( | 11:48 | |
m: my @a = [1,1],[2,2],[3,3]; my @b = $[4,4]; @a.splice(1,0,@b); dd @a | |||
camelia | Mu @a = [[1, 1], [4, 4], [2, 2], [3, 3]] | ||
ab5tract | lizmat++ | ||
lizmat | m: my @a = [1,1],[2,2],[3,3]; my @b = 4,4; @a.splice(1,0,$@b); dd @a | ||
camelia | Mu @a = [[1, 1], 4, 4, [2, 2], [3, 3]] | ||
librasteve | I think lizmat is arguing that both these are right and that the single argument rule applies to the splice arg ?? | ||
lizmat | no, I'm arguing that: | 11:49 | |
m: my @a = [1,1],[2,2],[3,3]; my @b = 4,4; @a.splice(1,0,$@b); dd @a | |||
camelia | Mu @a = [[1, 1], 4, 4, [2, 2], [3, 3]] | ||
lizmat | is wrong in ignoring the itemization of @b in $@b | ||
librasteve | ok - i agree with that | ||
lizmat | my @b = 4,4; and my @b = [4,4] is correct, because of the single arg rule | 11:50 | |
(producing the same result, I mean) | |||
librasteve | ok - I kinda get that ... the single arg rule is sometimes surprising to me ... but I do see the point | 11:51 | |
thanks for clarifying | |||
ab5tract | DarthGandalf: so a slightly less ugly workaround is also available: | 11:52 | |
m: my @a = 1,2,3; @a.splice(1,0,[$[3,5]],); dd @a | |||
camelia | Mu @a = [1, [3, 5], 2, 3] | ||
ab5tract | ignore the extra comma after `[$[3,5]]`, it's not necessary | 11:53 | |
DarthGandalf | I didn't use raku enough to develop taste to say which of them is uglier, but they look kinda the same to me :) | 11:54 | |
ab5tract | beauty is always in the eye of the beholder :) | 11:55 | |
13:15
teatime left
13:16
teatime joined
17:03
teatime left
22:19
habere-et-disper joined
|
|||
habere-et-disper | How do I access/reference the name of a variable ? | 22:21 | |
m: my $abc = '123'; say $abc.^name # wanting 'abc' ? | |||
camelia | Str | ||
MasterDuke | m: my $abc = '123'; say $abc.VAR.name | ||
camelia | $abc | ||
habere-et-disper | Thanks ! Does this also work on tokens ? | 22:24 | |
MasterDuke | good question. i have no idea, but probably | ||
m: my token foo { . }; say &foo.VAR.name | 22:25 | ||
camelia | foo | ||
lizmat | m: my token foo { . }; say &foo.name | 22:32 | |
camelia | foo | ||
MasterDuke | huh, why didn't my version print '&foo'? | 22:34 | |
lizmat | m: my sub foo { . }; say &foo.name | ||
camelia | ===SORRY!=== Error while compiling <tmp> Unsupported use of . to concatenate strings. In Raku please use: ~. at <tmp>:1 ------> my sub foo { . ⏏}; say &foo.name |
||
lizmat | m: my sub foo { }; say &foo.name | 22:35 | |
camelia | foo | ||
MasterDuke | m: my sub foo { }; say &foo.VAR.name | ||
camelia | foo | ||
MasterDuke | m: my @foo; say @foo.VAR.name | ||
camelia | @foo | ||
MasterDuke | m: my %foo; say %foo.VAR.name | ||
camelia | %foo | ||
lizmat | .VAR on a non-container is identity | ||
habere-et-disper | I was trying to get the name of a matched token in a grammar and .keys worked. | 22:38 | |
23:17
habere-et-disper left
|