🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 8 June 2022.
ToddAndMargo newbie question: is there a way I can create a buf such that I can dynamically add toit, like a string, or do I always have to allocate their size with the .new at creation? 03:38
melezhik Anton Antonov I do see last builds failed for Data Reshaper on sparkyci - sparrowhub.io:2222/report/665 hopefully you will this useful 06:44
nine TodddAndMargo: you dont have to allocate the size at all. Buf will auto grow when you docs.raku.org/type/Buf#method_push or assign to a position outside its current size 06:52
tellable6 nine, I'll pass your message to ToddAndMargo
Anton Antonov <@779471841270038528> Thanks — I will investigate. 07:25
ToddAndMargo anyone on newbie duty? 08:02
tellable6 2022-06-19T06:52:01Z #raku <nine> TodddAndMargo: you dont have to allocate the size at all. Buf will auto grow when you docs.raku.org/type/Buf#method_push or assign to a position outside its current size
ToddAndMargo Hi tellable6. Thank you!  got it working! 08:03
ToddAndMargo I have a string `$x ="0x1B, 0xB6, 0x7A, 0xE8, 0x5A"`.  I would like to load these values into a new buffer using `my buf8 $y = buf8.new( 0x1B, 0xB6, 0x7A, 0xE8, 0x5A )` EXCEPT I want to use the string variable to do such.  `my buf8 $y = buf8.new( $x )`  does not work.  How do I get a variable to work inside .new? 08:07
Nemokosch It was nine 😂 08:19
Tellable is the name of the IRC bot 08:20
Just like I'm writing via the discord bridge
Anyway... so the string contains all the data you'd like to pass? 08:21
ToddAndMargo yes 08:22
so far I wind up with with ord("0"),ord("x"),ord("1"),etc. using encode.  Not the hex values in the string 08:24
Nemokosch Perhaps not the nicest solution but you could definitely compose an EVAL call.
If you want to parse the string into values, split and comb can be your friend
ToddAndMargo can you show me a quick example using some of my values? 08:25
nine Start out with a string holding a single one of those values. Once you made it with that, you can try a string with multiple values.
Programming is all about making your own life easier.
Nemokosch docs.raku.org/routine/parse-base 08:26
ToddAndMargo My 2 cents: the purpose of a computer is to automate repatives tasks
Kaiepi ToddAndMargo, saw your mailing list post, but am unsure how to reply from thunderbird. there's a list of encodings in Encoding::Registry (src/core.c/Encoding/Registry.pm6), though it doesn't appear to be exposed beyond its find method 08:28
Nemokosch That's what scripting is all about, pretty much :)
Id go about it using comb and parse-base, that's for sure
ToddAndMargo any chance of a comb and parse-base example? 08:29
I am about to do it with a loop
Anton Antonov <@779471841270038528> I cannot reproduce that failure of sparrowhub.io:2222/report/665 . I just installed successfully the package on newly downloaded 2022.04 and 2022.06. I will try to make SparkyCI setup. 08:31
<@779471841270038528> I cannot reproduce that failure of sparrowhub.io:2222/report/665 . I just installed successfully the package on newly downloaded 2022.04 and 2022.06. I will try to make a SparkyCI setup.
Nemokosch I'm not at a PC so I might mess up sth 08:32
ToddAndMargo This would work in a loop: `> say "0xBB".Int.base(16)`  BB  Push the on one at a time 08:38
Nemokosch ```perl 08:39
my $x = '0x1B, 0xB6, 0x7A, 0xE8, 0x5A';
my @int-values <==
$x.comb: / '0x' <( <[0-9A-F]>{2} )> /
andthen .map: *.parse-base(16);
```
Id be happy if someone could check this
nine ToddAndMargo: of course you are free to ignore my advise. Your loss 08:41
ToddAndMargo Hi Nine, Do you mean "Start out with a string holding a single one of those values".  I have not been able to get that working 08:42
Nemokosch Oof 08:43
The thing is, I'm not sure about the interface of Buf itself 08:44
But what I posted, assuming I haven't messed it up, should turn the string into an array of integers with the right value 08:45
melezhik . 09:13
ToddAndMargo buf8 wont push an integer either 09:21
Did I just trip across a bug? > my uint8 $z = 0xBC; 09:25
188
[9] > say $z.base(16);
Cannot invoke object of type 'NQPMu'
  in any  at gen/moar/stage2/NQPCORE.setting line 893
`
nine m: my uint8 $z = 0xBC; say $z.base(16); 09:30
camelia BC
ToddAndMargo break it up into two lines: 09:36
thundergnat m: my $x = '0x84 0x73 0x77 0x84 0x79 0x87 0x84 0x68 0x73'; say Buf.new($x.match(/(<xdigit> ** 2)/, :g)».Str».Int).decode;
camelia TIMTOWTDI
ToddAndMargo > my uint8 $z = 0xBC; say $z.base(16); 09:37
BC
> my uint8 $z = 0xBC;
188
> say $z.base(16);
Cannot invoke object of type 'NQPMu'
  in any  at gen/moar/stage2/NQPCORE.setting line 893
That is the bug.
Fedora 35; rakudo-pkg-2022.6.0-01.x86_64
nine REPL has many issues 09:39
ToddAndMargo > my Str $x = '0x84 0x73 0x77 0x84 0x79 0x87 0x84 0x68 0x73' 09:40
0x84 0x73 0x77 0x84 0x79 0x87 0x84 0x68 0x73
> my buf8 $y = buf8.new($x.match(/(<xdigit> ** 2)/, :g)».Str».Int).decode;
Type check failed in assignment to $y; expected Buf[uint8] but got Str ("TIMTOWTDI")
  in block <unit> at <unknown file> line 1
REPL is getting better.  It use to not let me constrain variables with Str and such 09:41
thundergnat Well you've decoded it into a string. I just decoded it to demonstrate that it was indeed a buf. 09:44
m: m: my $x = '0x84 0x73 0x77 0x84 0x79 0x87 0x84 0x68 0x73'; say Buf.new($x.match(/(<xdigit> ** 2)/, :g)».Str».Int) 09:46
camelia Buf:0x<54 49 4D 54 4F 57 54 44 49>
ToddAndMargo Well, buf finally takes the data, but it does not come out right 09:49
> my Str $x = '0x84 0x73 0x77 0x84 0x79 0x87 0x84 0x68 0x73'
0x84 0x73 0x77 0x84 0x79 0x87 0x84 0x68 0x73
> my buf8 $y = buf8.new($x.match(/(<xdigit> ** 2)/, :g)».Str».Int);
Buf[uint8]:0x<54 49 4D 54 4F 57 54 44 49>
thundergnat Just be careful about decimal - hexadecimal conversion (like I screwed up above) 09:51
m: my $x = '0x54 0x49 0x4d 0x54 0x4f 0x57 0x54 0x44 0x49'; say Buf.new($x.match(/(<xdigit> ** 2)/, :g)».Str».parse-base(16));
camelia Buf:0x<54 49 4D 54 4F 57 54 44 49>
ToddAndMargo Works 09:52
thank you!
oops! 09:54
> my buf8 $y = buf8.new($x.match(/(<xdigit> ** 2)/, :g)».Str».Int);
Buf[uint8]:0x<54 49 4D 54 4F 57 54 44 49>
 > my buf8 $y = buf8.new($x.match(/(<xdigit> ** 2)/, :g)».Str».parse-base(16));
Buf[uint8]:0x<84 73 77 84 79 87 84 68 73>
still not right
Nemokosch Well, what's not right about it 09:55
ToddAndMargo 0x54 ne 0x84 and so on 09:58
thundergnat Like I said, be careful about decimal hexadecimal conversion. The ».Int was a thinko on my part. 09:59
Nemokosch Well it is the timtowdi string
And i would still pick comb over match :P 10:01
thundergnat TIMTOWTDI 10:02
Nemokosch You immediately don't need either :g or the >>.Str part
ToddAndMargo something is funny.  Give me a few minutes to double check some stuff
thundergnat Um. Well. Yes you do. 10:03
Nemokosch That seems kinda superior to me
thundergnat Oh wait, when you use comb. Ok yes you are correct. 10:04
Nemokosch :P
ToddAndMargo My fault.  Much better now.  I restart REPL and started over.
> my Str $x = '0x84 0x73 0x77 0x84 0x79 0x87 0x84 0x68 0x73'
> my buf8 $y = buf8.new($x.match(/(<xdigit> ** 2)/, :g)».Str».parse-base(16));
Buf[uint8]:0x<84 73 77 84 79 87 84 68 73>
thankyouthankyouthankyouthankyouthankyouthankyouthankyouthankyou 10:05
Nemokosch TIL <xdigit> and ** in regex 10:08
thundergnat You pick this stuff up over time. Raku is a large language. 10:09
And I've been messing around with it off and on since long before it was Raku 10:10
My oldest module is from 2010 10:11
Guest99 Hello 10:20
How do i loop chars backwards in a string? 10:21
my $word = "1234567890";
loop (my $i = 0; $i < $word.chars(); $i++) {
    say substr $word, $i, 1;
}
I can do it only forward
I want to see 0 9 8 7 6 5 4 3 2 1 10:22
Anton Antonov @Guest99 You can just do `$word.comb.reverse` 10:34
lizmat m: .say for "1234567890".flip.comb 10:36
camelia 0
9
8
7
6
5
4
3
2
1
Guest99 thank you very much 10:37
Anton Antonov @Guest99 If you really want to use a loop you can do:
```
for ($word.chars-1)...0 -> $i {
say substr $word, $i, 1;
}
```
lizmat m: my $word = "foo"; say $word.substr($_,1) for (^$word.chars).reverse 10:41
camelia o
o
f
ToddAndMargo Thank you! Signing off 10:45
Nemokosch What is flip? 11:51
Voldenet a move like this: o/ o` `o \o _o o_ o/ 11:54
a Str routine that reverses a string 11:55
Nemokosch this looks completely unreadable thanks to markdown 😅 12:41
uzl[m] m: say 'hello'.flip eq 'olleh' 13:05
camelia True
uzl[m] I wonder if there's a set of test cases for common data structures 🤔 Like let's say I'm implementing DFS traversal on a BT, it'd be nice to have a series of test cases that I could simply plug into my language's test suite 13:08
Voldenet I wonder if there's any plans to support things like python's `with` automatically closing the underlying resource 13:14
I'm using libarchive and `with archive-write("out.zip") { …; .close }` is bug-prone for no useful reason 13:17
Nemokosch yeah not sure it should be related to `with` though 13:30
that's rather confusing in Python as well
lizmat Voldenet: what is wrong with .spurt ? 13:35
Voldenet `libarchive` is the key word here, the full code is something like `with archive-write($storage.file, format => 'zip') { .write: 'file1', $blob; .close }` 13:45
and, ofc, I forgot the .close 13:46
it's minor pain though, doesn't happen often 13:47
lizmat docs.raku.org/routine/spurt#(IO::H...thod_spurt 13:59
.spurt: "file1", $blob ? 14:00
then you cannot forget the close ?
Voldenet but then you keep opening archive for every file 14:02
not exactly nice if you have more than 100 files
lizmat but wouldn't you need to re-open everytime if you're closing ?
lizmat apparently doesn't understand the problem 14:03
Voldenet `with archive-write($storage.file, format => 'zip') { for ^100 -> $n { .write: 'file' ~ $n, $n.Str; }; .close }` 14:04
lizmat hmm. I misread the docs: .spurt on IO::Handle actually doesn't close by default 14:09
on IO::Path it does :)
afk&
Util uzl[m]: I have also wished for such, for data structures and special functions. 15:29
I have had success scraping special function test data from www.boost.org/ ; the Stanford GraphBase *might* have what you need for some data structures: www-cs-faculty.stanford.edu/~knuth/sgb.html
Anton Antonov I see that the routine `combinations` produces sorted lists -- each list is a combination -- but is that guaranteed ? 16:43
Nemokosch docs.raku.org/routine/combinations 16:48
okay gg I might have missed the key word 16:49
"sorted"
But then I'm not sure what you mean, actually
you mean that the elements appear in the same order as in the original list? 16:51
Anton Antonov Yes! Thanks.
See this code:
```
my $t = ("A"..."F").pick(6);
say $t;
say $t.combinations(3)
```
Nemokosch hm I don't see any note about it in the docs... Roast should be checked 16:53
japhb Anyone know how to deal with the MacOS "loading libcrypto in an unsafe way" failure on GHA? 20:25
github.com/japhb/Cro-CBOR/runs/695...e#step:7:5 20:26
lizmat japhb : github.com/rakudo/rakudo/blob/mast...S.md#macos 20:29
uzl[m] Util: Thanks! Any specific directories you remember looking? 20:39
japhb lizmat: Ah thank you. What a damn mess 20:40
lizmat yeah, jnthn is also becoming more and more enamoured with MacOS. Not.
japhb That plus the inability to create long-lived test certs (so requiring new releases of otherwise stable code just to make cert validation happy for -- again -- TEST certs) is making me grumbly today. 21:07
El_Che japhb: what do you need specifically as certs? 21:23
(longest is 1y nowadays)
japhb El_Che: Yeah, I know about the 1 year limit. What I want is for my otherwise completely stable code to not suddenly break because I didn't notice the TEST cert's window expiring. I keep emphasizing TEST because it's bloody annoying when tests break for reasons completely unrelated to whether the code works. :-( 21:25
It's hostile to people who contribute heavily to the ecosystem.
El_Che japhb: and a long-lived self signed one + CA is not an option? 21:27
japhb El_Che: Last I checked, a long-lived self-signed will fail validation. The 1 year limit for leaf certs seems to be hard-enforced. 21:28
El_Che I ask because I don't know how you validate stuff 21:32
with openssl, by example, you can give the CA to use for validation
(I don't know the code if it was not clear :) ) 21:33
japhb Right, you can override the CA, and that's expected for a test cert, but that doesn't help with the 1 year limit on the leaf cert, unless I'm misunderstanding you. 22:20
Xliff If I were to get a new Mac, what should I get? 22:34
vrurg Xliff: depends on you budget and the purpose. 22:36
Xliff vrurg: ~1800. Raku dev and general Mac use 22:38
vrurg I'd consider a mini, unless you need a portable. 22:41
Xliff Yeah, that's what I'd like, too. 23:23
Any particular models in mind?
vrurg Xliff: there is not so many options. Best is just to play with the constructor on the site. 23:32
Surprisingly, they still sell Intel version. 23:33
vrurg Xliff: What I don't like is the 16GB limit on M1 minis. I'd try to go a little over the budget and consider a Studio with M2 and 32G in the base. 23:38
SmokeMachine Are there studios with M2 already?! I thought M2 was only for Mac book air and pro for now… 23:46
Geth ¦ doc: coke self-assigned Fix duplicated index entries and avoid them in the future by adding a test. github.com/Raku/doc/issues/1912 23:50
Voldenet It would be very useful to set up mac m1 VM from x86 machine, I wonder if anyone even tries implementing that
[Coke] lizmat: Geth is reporting on assignment of issues in doc, but not creation of new issues 23:58
added github.com/Raku/doc/issues/4090 for anyone on the *-users list