7 Dec 2021
Nemokosch While Bag.new would keep the lists as the elements 00:20
moreover Bag.new doesn't count the duplicates 00:46
this is a bit cruel. It compares with === and (1,2) fails on that, no matter that it's immutable 00:48
(1,2) !=== (1,2)
I can get by by converting the lists into pairs that do match by === but frankly, one would expect identity to work on plain immutable data 00:53
hm, it works with the data sigil! 00:55
\\(1,2) === \\(1,2)
gfldex I would be really careful to use `===`. You are in C-land if you do. 00:56
Nemokosch I don't use it - Bag does... 00:57
this leads to another question - what is (1,2) actually?
if it's apparently not the same as \\(1,2)
is it the same as @(1,2)?
gfldex Those are instances of `Capture`. Raku-Objects are just C-pointers under the hood. Since value objects are cached, they can return `True` on `===`. 00:59
Nemokosch they can whenever they feel like or are they guaranteed to?
gfldex if you do `1 === 1` you rely on the fact that the compiler reuses the object that is `1`.
The spec demands as such.
If you ask me to list all types that are considered values, I would be at a loss.
Nemokosch so I can call .Capture on a list to get this \\ version? 01:01
gfldex m: put (1,2,3,4).&{ say $_, $_}.Capture.raku; 01:02
m:``` 01:03
put (1,2,3,4).&{ say $_, $_}.Capture.raku;
```
m: (1,2,3,4).Capture.raku.put;
Nemokosch okay, this worked, thank you 🙂 01:07
Can I get a downwards range? 01:28
in fact, the sequence operator will do just fine but I'm still curious 01:30
I wonder what happens when writing Z... 01:34
m: dd (8, 10) Z... (16, 2)
it seems to me that basically a plain zip call happens
Z.. produces ranges tho
m: dd (8, 10) Z.. (16, 2)
I'm pretty sure the former is related to list associativity again because I got an error for an $a ... $b Z $c ... $d kind of call 01:38
gfldex m: dd &infix:<..>; 01:59
I would have guessed that to be some grammar magic. It's operators all the way down. :) 02:01
Nemokosch How does ... work though? 10:09
gfldex m: &infix:<...>; 13:59
m: dd &infix:<...>; 14:00
Nemokosch hmmm 14:34
`(|)`
How can I unite lists? 14:50
lakmatiol `[|@a,|@b]` I have seen in the docs quite a bit 14:56
Nemokosch it works I guess... I kinda miss an operator for this 15:05
gfldex m:``` 15:55
multi sub infix:«|,»(\left, \right) is equiv(&infix:<Z>) { |left, |right }
```
SmokeMachine m: my @a = 1,2,3; my @b = <a b c>; @a.push: |@b; say @a # if you want to mutate it... 17:28
camelia [1 2 3 a b c]
SmokeMachine m: my @a = 1,2,3; my @b = <a b c>; @a.append: @b; say @a
camelia [1 2 3 a b c]
Nemokosch yes, I know that part 17:52
is there a placeholder argument in signatures, indicating that I don't care about a certain argument for the return value?
gfldex m: say sub subby($a, $, $b){}; subby(1,2,3); 17:56
Nemokosch oh fine