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:40 deoac joined
deoac What determines which methods also have a sub version?  For example: 00:42
``` 00:43
sub join($separator, *@list)
method join(List:D: $separator = "")
```
In particular, why is there no sub version of method match()?
avuserow deoac: I'm guessing because it would usually be done by an operator (e.g. $foo ~~ /bar/) 00:58
I suspect the answer is approximately: if it had a subroutine form in Perl 5, and it wasn't moved out of core (e.g. dbmopen and the like), then it has a subroutine form in Raku. Then anything that's new but very similar to a P5 subroutine also gets one (e.g. append, since it's similar to push) 01:03
If you have a good case for the existence of a subroutine form of something, might be worth a mention. I think that rotor is gaining a sub version in 6.e so there is precedent for expansion 01:06
deoac I discovered this when I tried to use match() with the feed operator (==>).  I'm not sure that is a 'good case'... :-) 01:08
avuserow I keep forgetting about the feed operator. I'd love to see some great use cases of it. 01:23
01:29 deoac left 01:34 aqua2 left 02:23 teatwo joined 02:26 tea3po left 02:30 deoac joined 05:55 deoac left
nemokosch > What determines which methods also have a sub version? the shortest, simplest and most accurate answer would be: nothing 09:34
whether somebody created one or not
I asked for a couple of new subroutine forms (not sure which one but something array-related probably) like a year ago and got them 09:35
14:22 teatwo left 14:23 teatwo joined 14:48 deoac joined
deoac m: my @a = <1 a>, <2 b>, <3 c> 15:20
camelia ( no output )
deoac m: my @a = <1 a>, <2 b>, <4 c>; say \@a 15:21
camelia Potential difficulties:
To pass an array, hash or sub to a function in Raku, just pass it as is.
For other uses of Perl's ref operator consider binding with ::= instead.
Parenthesize as \(...) if you intended a capture of a single va…
deoac m: my @a = <1 a>, <2 b>, <4 c>; say @a
camelia [(1 a) (2 b) (4 c)]
deoac How can I flatten this list?  slip, .Slip, `|`, >>.List>>.Slip, etc.  work. 15:23
DON'T work, i meant
m: say gather @a>>.take
camelia ===SORRY!=== Error while compiling <tmp>
Variable '@a' is not declared. Perhaps you forgot a 'sub' if this was
intended to be part of a signature?
at <tmp>:1
------> say gather ⏏@a>>.take
deoac m:  my @a = <1 a>, <2 b>, <4 c>; say gather @a>>.take 15:24
camelia (1 a 2 b 4 c)
deoac Which surprised me, I thought I would get a 3-element Seq 15:25
CIAvash m: my @a = <1 a>, <2 b>, <4 c>; say @a; say @a.map: |* 16:05
camelia [(1 a) (2 b) (4 c)]
(1 a 2 b 4 c)
CIAvash m: my @a is List = <1 a>, <2 b>, <4 c>; say @a; say flat @a 16:06
camelia ((1 a) (2 b) (4 c))
(1 a 2 b 4 c)
nemokosch m: my @a = <1 a>, <2 b>, <4 c>; say @a; @a>>.Slip.say 16:07
Raku eval [(1 a) (2 b) (4 c)] ((1 a) (2 b) (4 c))
nemokosch oh come on, why would it slip to itself
m: my @a = <1 a>, <2 b>, <4 c>; say @a; @a.map(*.Slip).say; 16:08
Raku eval [(1 a) (2 b) (4 c)] (1 a 2 b 4 c)
CIAvash » is not like map, it goes deep to the elements
nemokosch ... unless the method is "nodal", which is basically a random guessing game 16:09
like it would make sense for Slip to be "nodal" since it only makes sense on some sequence of values
CIAvash yeah, maybe 16:24
deoac Thanks, food for thought.  Though I don't see the logic why 'is List' makes a difference. 18:30
19:07 jgaz left
CIAvash deoac: It's about containers, Array and Scalar. Array's elements are items(Scalar containers) and items do not get flattened along with the array containing them. Not sure the docs do a good job explaining it: docs.raku.org/language/containers#...containers 19:08
using binding also creates a list: `my @a := <1 a>, <2 b>, <4 c>;` 19:11
deoac Thanks for the link.   I didn't understand the line: 20:30
flat, in the other hand, flattens all elements including the elements of the included array, except for (9 10)
Why not (9, 10)?