gfldex | m:``` | 01:22 | |
my \p1 = a => 1; | |||
my \p2 = b => 2; | |||
my \p3 = a => 1; | |||
say p1 ~~ p2; | |||
say p1 ~~ p3; | |||
``` | |||
@Nemokosch#9980 what do you want to match the pairs against? | 01:23 | ||
01:42
parv left
03:48
parv joined,
parv left,
parv joined
|
|||
Nemokosch | Well, what are the possibilities? | 08:02 | |
It would be cool to match based on the key | |||
lakmatiol | I can think of `p ~~ {.k ~~ sth}`but there may be a better way | 08:25 | |
oh it isn't .k | |||
I can think of `p ~~ {.key ~~ sth}`but there may be a better way | 08:26 | ||
``` | 08:27 | ||
> :6a ~~ ('a' => Any) | |||
True | |||
```this also works | |||
08:45
discord-raku-bot left
08:46
discord-raku-bot joined
|
|||
Nemokosch | this works badly, though | 08:50 | |
```perl | |||
> :6a ~~ ('b' => Any) | |||
True | |||
``` | |||
08:51
riffraff joined
10:00
riffraff left
|
|||
lakmatiol | huh | 10:43 | |
11:22
parv left
11:45
parv joined,
parv left,
parv joined
11:47
sivoais joined
|
|||
gfldex | m:``` | 12:12 | |
my \p1 = a => 1; | |||
my \p2 = b => 2; | |||
my \p3 = a => 1; | |||
say p1 ~~ p2; | |||
say p1 ~~ p3; | |||
say p1<a>:exists; | |||
say p2<a>:exists; | |||
say p1{p2.key}:exists; | |||
say p1{p3.key}:exists; | |||
``` | |||
12:13
discord-raku-bot left,
discord-raku-bot joined
|
|||
@Nemokosch#9980 In the end a `Pair` is just a very small `Hash`. | 12:14 | ||
lizmat | m: dd (a => 42).kv | ||
camelia | ("a", 42).Seq | ||
Nemokosch | I could ask the same for hashes as well | 12:15 | |
for lists, something like this seems to work: | |||
<a 34> ~~ ['a', *] | |||
m: dd <a 34> ~~ ['a', *] | |||
lizmat | yeah, smartmatching two lists will smartmatch corresponding elements | ||
and short-circuit as soon as one fails | 12:16 | ||
Nemokosch | is there anything like this for hashes? | ||
lizmat | I think it will smartmatch the pairs, which will smartmatch key and value ? | ||
it may shortcut on number of elems in both cases | 12:18 | ||
Nemokosch | why is | 12:19 | |
m: dd :2f ~~ :2b | |||
True | |||
gfldex | m:``` | ||
my %h = :a1, :b2, :c3; | |||
my $p = :a1; | |||
say %h.keys ~~ $p.key; | |||
``` | |||
Nemokosch | even this is unintuitive | 12:21 | |
let alone this, this is madness | |||
gfldex | m:``` | ||
my %h = :a1; | |||
my $p = :a1; | |||
say %h.keys ~~ $p.key; | |||
``` | |||
lizmat | hmm... looks like Pair.ACCEPTS only looks at value | ||
gfldex | What does roast say to that? | 12:23 | |
lizmat | one would have to look :-) | 12:25 | |
Nemokosch | is there a way to add multiple arrays value by value? | 12:50 | |
seems like something for hyper | |||
lizmat | m: my @a = ^5; my @b = |@a, |@a, |@a; say @b | 12:51 | |
camelia | [0 1 2 3 4 0 1 2 3 4 0 1 2 3 4] | ||
12:51
riffraff joined
|
|||
gfldex | Smartmatch on `Pair` might just look at keys because a key can be of any type. | 12:53 | |
Nemokosch | [>>+>>] is this legit? | 12:54 | |
hyper reduction 😄 | |||
gfldex | I don't think that works. | ||
Nemokosch | \> [>>+>>] [[1,2],[3,4],[5,6]] | ||
[9 12] | |||
12:55
riffraff left
|
|||
I mean it's not baseless but I'm not sure whether it's reliable | 12:55 | ||
12:55
riffraff joined
|
|||
gfldex | It is in `S02-types/pair.t`. So, working as intended. | 12:56 | |
Nemokosch | It seems nobody knows just exactly what Raku is actually capable of, lol | 12:57 | |
gfldex | m: &[>>+>>].WHAT.say; | ||
12:58
riffraff left,
riffraff joined
|
|||
m: say &infix:«>>+>>».WHAT.say; | 12:58 | ||
13:00
riffraff left,
riffraff joined
|
|||
That I don't know stuff does by no means mean that it's unknown. | 13:00 | ||
Nemokosch | it's not only you who doesn't know stuff | ||
I'm yet to come across someone who doesn't bump into new things regularly | 13:01 | ||
I think even Larry Wall could be surprised a couple of times | 13:02 | ||
gfldex | m: my &subby = { $^a + $^b }; say [&subby] 1,2,3,4; | ||
m: my &subby = { $^a + $^b }; say [subby] 1,2,3,4; | 13:03 | ||
13:04
riffraff left
|
|||
m: my &subby = { $^a + $^b }; say [{subby}] 1,2,3,4; | 13:04 | ||
13:13
riffraff joined
13:22
riffraff left,
riffraff joined
13:27
riffraff left,
riffraff joined
13:32
riffraff left
13:34
riffraff joined
13:35
riffraff left,
riffraff joined,
parv left
13:59
A26F64 joined
14:07
riffraff18 joined
14:11
riffraff left
15:54
riffraff18 left,
riffraff18 joined
|
|||
Nemokosch | by the way, something seems strange | 15:54 | |
m: dd [>>+>>] [<1 2 3>, <4 5 6>] | 15:55 | ||
hmmm | |||
why is it scalar | 15:56 | ||
m: dd <1 2 3> >>+>> <4 5 6> | |||
indeed, why is it | |||
16:10
gfldex left,
discord-raku-bot left
16:13
riffraff18 left,
riffraff18 joined
16:29
mmat joined
16:53
riffraff18 left
16:54
riffraff18 joined
16:58
riffraff18 left
16:59
mmat left
17:17
aoeuidhtns joined
18:18
riffraff18 joined
18:22
riffraff18 left,
riffraff18 joined
18:27
riffraff18 left
19:17
riffraff18 joined
19:19
riffraff18 left
19:20
riffraff18 joined
19:24
riffraff18 left
19:46
riffraff18 joined
19:56
riffraff18 left,
riffraff18 joined
19:59
riffraff18 left,
riffraff18 joined
20:00
riffraff18 left
20:01
riffraff18 joined
20:05
riffraff18 left
20:07
riffraff18 joined
20:14
riffraff18 left,
riffraff18 joined
20:18
riffraff18 left
20:34
A26F64 left
20:38
riffraff18 joined
20:46
riffraff18 left
20:47
riffraff18 joined
20:51
riffraff18 left
20:53
discord-raku-bot joined
20:55
discord-raku-bot left
20:57
discord-raku-bot joined,
riffraff18 joined
20:58
parv joined
21:03
aoeuidhtns left
21:08
gfldex joined
21:23
riffraff18 left,
riffraff18 joined
21:59
riffraff18 left
22:00
riffraff18 joined
22:04
riffraff18 left,
riffraff18 joined
22:09
riffraff18 left
22:52
discord-raku-bot left
|