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:03 deoac left 00:13 habere-et-disper left 00:26 Kaiepi left 00:29 Kaiepi joined
guifa habere-et-disper it's doing scalar-style assignment 01:00
m: my UInt ( $foo, @bar ) := ( 3, [14] ); say $foo, @bar; 01:01
camelia 3[14]
guifa binding works though
01:56 Kaiepi left 02:01 razetime joined 02:04 frost joined 03:03 frost left 03:05 frost joined
jaguart m: my @foo of Int = 33,44,'a'; 03:22
camelia Type check failed in assignment to @foo; expected Int but got Str ("a")
in block <unit> at <tmp> line 1
jaguart m: my ( @foo of Int) = 33,44,'a'
camelia ( no output )
jaguart hmm my repl says this results in ([33 44 a]) 03:23
m: my (UInt $foo, @bar of UInt ) = ( 3, 14,15,'a' ) 03:24
camelia ( no output )
jaguart m: my (UInt $foo, @bar of UInt ) = ( 3, 14,15,'a' ); @bar.raku 03:25
camelia ( no output )
jaguart Again, my repl (2022.7) ends up with @bar containing an 'a' 03:26
guifa jaguart: I can confirm that. And it's that the `of Foo` isn't applied
golfed: 03:27
m: my (@foo of Int) = 1,'a'; say @foo; say @foo.of
camelia [1 a]
(Mu)
jaguart it works as expected with no brackets :o 03:28
guifa The parentheses induce special handling, and certain attributes aren't be applied as a result 03:32
jaguart M: my (UInt @bar) = 1,2; @bar.raku 03:34
gives this in my repl: Array[<anon>].new(1, 2)
m: my UInt @bar = 1,2; @bar.raku 03:35
camelia ( no output )
jaguart gives: Array[UInt].new(1, 2)
m: my UInt @bar = 1,2; say @bar.raku 03:38
camelia Array[UInt].new(1, 2)
jaguart m: my (UInt @bar) = 1,2,'a'; say @bar.raku
camelia Type check failed in assignment to @bar; expected <anon> but got Str ("a")
in block <unit> at <tmp> line 1
jaguart m: my (@bar of UInt) = 1,2,'a'; say @bar.raku 03:39
camelia [1, 2, "a"]
03:46 razetime left 04:32 razetime joined 04:53 Heptite left 05:50 frost left 06:02 razetime left 06:03 razetime joined 06:12 razetime left, razetime joined 07:26 Kaiepi joined 07:34 Kaiepi left 07:39 razetime left, razetime_ joined 07:45 razetime_ is now known as razetime, razetime left, razetime joined 07:46 habere-et-disper joined 07:48 Kaiepi joined 08:08 frost joined 08:18 razetime left 08:19 frost left 08:24 frost joined 09:12 dakkar joined 09:31 codesections left
rcmlz Hello, I was wondering whether there is a more Rakuish way of generating all subsequences in an array. The function .combinations gets close, but I did not succeed in finding a correct usage. Here is my not-so-nice solution, any thoughts on how to make that more elegant? 10:28
m:
sub subsequences(@input){
my $n = @input.elems();
my @result;
for ^$n {
my $subseq_len = $_ + 1;
for ^$n -> $i { # start at every element of array
my @subsequenz;
@subsequenz.append(@input[$i]);
for 1..^$subseq_len -> $j { # add $subseq_len elements
@subsequenz.append(@input[$j]);
}
m: 10:30
sub subsequences(@input){
my $n = @input.elems();
my @result;
for ^$n {
my $subseq_len = $\_ + 1;
for ^$n -> $i { # start at every element of array
my @subsequenz;
@subsequenz.append(@input[$i]);
for 1..^$subseq_len -> $j { # add $subseq_len elements
@subsequenz.append(@input[$j]);
}
lizmat please post code in a gist 10:31
rcmlz How do I post code in a gist? 10:36
Nahita hello rcmlz i think they mean gist.github.com/ or pastebin.com/ or hastebin.com/ kind of things 10:40
rcmlz gist.github.com/rcmlz/5c33ae1a2cd2...b23c7a1c14
Nahita because the message is from IRC bridge and not sure how multiple line code blocks are seen there
rcmlz <@836605577400549436> Thank you. I was reading gist() in Raku and did not get it. Now it is clear. 10:42
10:46 rcmlz joined
I logged in to IRC to see what a mess I created there by pasting so much code ... 10:52
irclogs.raku.org/raku-beginner/live.html shows me, that indeed it became unreadable. Sorry, I did not know that. Will use gist in the future. 10:53
lizmat thank you :-)
sorry for being a bit grumpy in the early morning
10:54 frost left
lizmat looking at the gist, feels like lines 9-11 can be simplified to: 10:56
@subsequenz.append(@input[1..^$subseq_len]);
rcmlz Hello, I was wondering whether there is a more Rakuish way of generating all subsequences in an array. The function .combinations gets close, but I did not succeed in finding a correct usage. Here is my not-so-nice solution, any thoughts on how to make that more elegant? 10:57
gist.github.com/rcmlz/5c33ae1a2cd2...b23c7a1c14
lizmat I see that you want to return a Set at the end
perhaps docs.raku.org/type/SetHash#method_set could be of use ? 10:58
so not create an array, but create a SetHash
rcmlz No, Set or Array does not matter 10:59
lizmat if you really want to return an immutable Set, you could coerce it to a Set on line 15
rcmlz array, list, set - anything I can later itterate over is fine
lizmat : indeed, using the range saved me one loop. gist.github.com/rcmlz/3e604059949f...80265459a2 11:29
11:30 frost joined 11:33 rcmlz left 11:48 habere-et-disper left 12:03 rcmlz joined 12:05 rcmlz left 12:19 frost left 12:28 rcmlz joined 12:43 rcmlz left 13:22 mahafyi joined 13:49 rcmlz joined 13:59 codesections joined
mahafyi Inline::Perl will use only system installed version, or can allow for a perlbew verision also? 14:08
14:49 mahafyi left 15:02 codesections left 15:04 codesections joined
rcmlz I developed two versions of a function that are doing the same. Is there a prefered way in Raku to compare the performance of them depending on the input size? gist.github.com/rcmlz/3e604059949f...80265459a2 15:25
How do you usually measure speed and memory usage of two alternatives? 15:27
15:33 razetime joined 16:22 razetime left 16:23 razetime joined 16:25 rcmlz left 16:28 rcmlz joined 16:29 Heptite joined 16:51 codesections left, codesections joined 17:07 codesections left 17:08 codesections joined 17:20 razetime left 17:26 rcmlz left 17:32 dakkar left 17:44 codesections left 17:45 codesections joined 18:02 mahafyi joined
avuserow rcmlz: there are a few Benchmark modules in the ecosystem. I've been using "Bench" lately. There's also Benchmark and Benchy. 19:13
.tell rcmlz there are a few Benchmark modules in the ecosystem. I've been using "Bench" lately. There's also Benchmark and Benchy.
20:06 codesections left 20:08 codesections joined 20:25 ToddAndMargo joined, ToddAndMargo left, ToddAndMargo joined 20:46 tirnanog joined 20:52 codesections left, codesections joined 20:59 ToddAndMargo left 21:00 codesections left 21:01 codesections joined 21:42 ToddAndMargo joined 22:21 codesections left 22:23 codesections joined, codesections left 22:24 codesections joined, codesections left 22:25 codesections joined 22:28 codesections left, codesections joined 22:31 ToddAndMargo left 22:48 bigfondue left 23:18 codesections left 23:19 codesections joined 23:29 Heptite left 23:33 Heptite joined 23:34 codesections left 23:35 codesections joined 23:53 codesections left 23:54 codesections joined, codesections left 23:55 codesections joined 23:56 codesections left 23:57 codesections joined, codesections left