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
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
Nemokosch this works badly, though 08:50
```perl
> :6a ~~ ('b' => Any)
True
```
lakmatiol huh 10:43
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;
```
@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]
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]
I mean it's not baseless but I'm not sure whether it's reliable 12:55
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;
m: say &infix:«>>+>>».WHAT.say; 12:58
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
m: my &subby = { $^a + $^b }; say [{subby}] 1,2,3,4; 13:04
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