00:17 Xliff joined
Xliff \o 00:17
Can someone confirm something for me, pls?
m: "/proc/net/tcp".IO.say
camelia "/proc/net/tcp".IO
Xliff m: "/proc/net/tcp".IO.slurp.say 00:18
camelia sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
0: 00000000:0016 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 22848609…
Xliff I get more lines when I 'cat /proc/net/tcp' than I do when I have raku '"/proc/net/tcp".IO.slurp'
Is this a feature, not a bug?
kjp I get the same result (lots of lines) here either way. 00:22
Xliff Same number of lines from `cat` as from `raku`? 00:23
teatwo how many more lines? one more? twice as many? 00:31
Xliff About twice, yes.
teatwo how do you count them, wc -l? 00:32
Xliff Look at the first token on the line.
The last token I get from raku is "25:"
From cat "72:"
teatwo i'm sorry I don't understand
Xliff In raku: '"/proc/net/tcp".IO.slurp.lines.elems" 00:33
in shell "wc -l /proc/net/tcp"
And that should be...
In raku: '"/proc/net/tcp".IO.slurp.lines.elems.say"
teatwo oh sorry I don't have access to to a shell atm 00:34
Xliff On my system I get: 27 (raku) and 95 (shell)
No worries, I guess.
00:39 Sgeo joined 00:44 vlad joined 00:48 Manifest0 left
[Coke] try .slurp(:close) 00:58
> 01:00
?
Xliff Same thing 01:29
01:29 hulk joined, kylese left
Xliff And from what I can tell, it's only /proc/net/tcp (and I would guess other /proc entries) that suffers from this. 01:29
So the difference between shell and raku should be concerning. 01:30
I get the same results, even as root. 01:31
antononcube @Xliff You are giving me ideas to test /break "Data::Importers". (Formerly known as "Data::Slurpers".) 01:32
Xliff antoncube: What does that do? 01:43
antononcube: Can you replicate what I am seeing? 01:45
In raku: '"/proc/net/tcp".IO.slurp.lines.elems.say"
in shell "wc -l /proc/net/tcp"
On my system, they are not the same.
Why is that/
It seems like raku will always slurp in a certain amount of data before ending 01:46
Where as cat will go to the proper end.
Using the .slurp from a IO::Handle works properly, though! 01:48
[Coke] is firing up a linux box on azure to check 01:50
Xliff Thanks, [Coke] 01:51
[Coke] I get 7 and 8 here, which might be a trailing newline 01:52
Xliff '"/proc/net/tcp".IO.open( :r ).slurp( :close ).lines.elems.say' # Gets whole file
[Coke] ah, no 01:53
Xliff No?
[Coke] if I run them on the same line, I get the same number here.
Xliff Don't run them on the same line
[Coke] this with rakudo HEAD and #38~20.04.1-Ubuntu SMP Mon Jan 9 18:23:48 UTC 2023 01:54
Xliff You might need to open more connections. Sounds like file is to small
Rakudo™ v2024.03-16-gc7d24b3df.
antononcube @Xliff "What does that do?" -- The package "Data::Importers" is supposed to provide an universal "importer" or "slurper" function / sub. Right now it ingests PDFs, HTMLs, images, and text for arguments that URLs, file names, or strings. 01:55
Overloads the built-in slurp.
Xliff antononcube: OIC ... nice package! 01:56
However this is more IO::Path, IO::Handle stuff
[Coke] if you're running them at different times, can you expect the same data? (I'm now regularly getting 6 either way)
Xliff [Coke]: Yes.
Your file might be too small. 01:57
Open up a web browser or an irc bot.
[Coke] This machine is a cli only linux box in the cloud. 01:58
Xliff Ah.
OK, then. Thanks for looking.
[Coke] sorry it wasn't more helpful! 02:01
ugexe I get different number of rows between invocations using cat 02:02
Xliff It will change as you open connections. 02:04
However reading the file using IO::Path.slurp in raku is consistently and noticeably smaller than what I get with cat or IO::Handle.slurp
'"/proc/net/tcp".IO.slurp( :close ).lines.elems.say' # 27 02:05
'"/proc/net/tcp".IO.open( :r ).slurp( :close ).lines.elems.say' # 48 02:06
02:06 vlad left
Xliff And on that note, I have to hit the hay. 02:06
02:07 Xliff left 02:15 hulk left, kylese joined 02:42 haxxelotto left, gfldex left 03:38 gfldex joined 05:18 abraxxa joined 05:35 holyghost left 06:00 Sgeo left 07:38 Manifest0 joined 07:50 vlad joined 08:11 dakkar joined 08:17 ptc joined 08:30 sena_kun joined 08:39 haxxelotto joined 09:22 sena_kun left 09:26 haxxelotto left 09:27 haxxelotto joined 09:33 zara joined 09:34 zara left
librasteve o/ 09:49
hi folks - is there an idiomatic way to take a 2D slice from a 2D array?
m: my @m = [[1,2,3],[4,5,6],[7,8,9],]; dd @m[^2,^2];
evalable6 (($[1, 2, 3], $[4, 5, 6]), ($[1, 2, 3], $[4, 5, 6]))
Raku eval (($[1, 2, 3], $[4, 5, 6]), ($[1, 2, 3], $[4, 5, 6]))
librasteve oops 09:50
my @m = [[1,2,3],[4,5,6],[7,8,9],]; dd @m[^2;^2];
evalable6 (1, 2, 4, 5)
librasteve ^^ this one gives a 1D List ;-( 09:51
lizmat to be clear: you'd want ((1,2), (4,5)) as a result, right? 09:56
librasteve yep 10:17
lizmat I'm not sure this is currently possible in core 10:26
librasteve ok - there's likely a cool way with .map 10:27
lizmat for sure 10:30
and possibly abstractable into a nice subroutine
10:30 hudo left
librasteve m: my @m = [[1,2,3,],[4,5,6,],[7,8,9,],]; sub slice2d(@m, \R, \C) {@m[R].map(*[C])}; say @m.&slice2d(^2, ^2); 10:35
evalable6 ((1 2) (4 5))
Raku eval ((1 2) (4 5))
lizmat :-) 10:36
librasteve aka polyslice? (ie in N dims)
lizmat possibly, but an unshaped array we don't know the number of dimensions of 10:37
10:42 amenonsen left
librasteve yeah - probably doing this "properly" when shaped arrays are next improved 10:47
m: my @a[3,3] = [[1,2,3],[4,5,6],[7,8,9]]; my @b[2,2]; say @b = @a[^2;^2]; 10:48
evalable6 (exit code 1) Partially dimensioned views of shaped arrays not yet implemented. Sorry.
in block <unit> at /tmp/_yZ4uGFzte line 1
Raku eval Exit code: 1 Partially dimensioned views of shaped arrays not yet implemented. Sorry. in block <unit> at main.raku line 1
lizmat I did do a lot of work on shaped arrays
m: use v6.*; my @a[3,3] = [[1,2,3],[4,5,6],[7,8,9]]; my @b[2,2]; say @b = @a[^2;^2];
camelia Partially dimensioned views of shaped arrays not yet implemented. Sorry.
in block <unit> at <tmp> line 1
lizmat meh
librasteve ^^ lloks like you already thought of this then (per the error msg)
lizmat m: use v6.*; my @a[3,3] = [[1,2,3],[4,5,6],[7,8,9]]; my @b[2,2]; dd @a[^2;^2]; 10:49
camelia Partially dimensioned views of shaped arrays not yet implemented. Sorry.
in block <unit> at <tmp> line 1
lizmat m: use v6.*; my @a[3;3] = [[1,2,3],[4,5,6],[7,8,9]]; my @b[2,2]; dd @a[^2;^2];
camelia Partially dimensioned views of shaped arrays not yet implemented. Sorry.
in block <unit> at <tmp> line 1
lizmat my mind is currently in way other directions, sorry 10:50
librasteve no worries
11:13 teatwo left
tbrowder interesting. mod i'm working on handles empty cells and fills out rows with empty cells so that's a sparse matrix repr 11:21
11:22 vlad_ joined 11:26 vlad left 11:33 Aedil left 11:37 Aedil joined
tbrowder desired query: @arr[<index range>; <index range>]; yes? 11:50
12:07 jpn left 12:09 jpn joined 12:52 teatime joined
tbrowder ok, i'll add a .slice method 12:55
returning a 2D array of arrays (with an option for empty cells to be filled with a value; optionally defined in the class constructor) 12:58
13:16 perlbot left, simcop2387 left 13:22 haxxelotto left 13:34 simcop2387 joined 13:36 perlbot joined 13:54 ptc left
tbrowder hm, .slice(Range $a, Range $b) would enable that calc 14:14
14:32 ptc joined 14:34 haxxelotto joined 14:49 vlad_ left 14:53 vlad_ joined 14:56 vlad__ joined 15:00 vlad_ left
antononcube I think the following question was recently discussed here. How can read/load/ingest a Raku file with variable and functions definitions in the working sesion? I tried to use use lib <file-name> without success. (In Jupyter.) 15:32
Wsing EVAL does not work either.
15:35 silug left 15:36 silug joined
_grenzo Would require work? 15:38
antononcube @_grenzo Thanks! Did not work as I expected, but it made me read the documentation around it, that actually helped me to find the right approach. 15:50
_grenzo What did work? 15:51
15:55 jpn left
antononcube Ok, I made it with work with require. (Apparently, I forgot how to use require properly...) 16:03
I have a file with LLM services access configurations. So here is my loading code: use lib <.>; require LLMConfigurations <$conf3 $conf4 $conf4-turbo $conf-gemini $conf-gemini-preview>; 16:10
It is more involved than I want/prefere, but still it is more concise than what I used before... 16:12
16:13 vlad__ left
ugexe require WHATEVER:file</Users/nlogan/repos/Foo.rakumod> <$x>; say $x 16:20
you can use something like that too which might be better for you since you don't need to add a library path
antononcube @ugexe Great!
16:25 vlad joined 16:47 dakkar left 16:52 ptc left 17:25 sena_kun joined 17:54 haxxelotto left 18:07 jpn joined 18:24 vlad_ joined 18:26 jpn left 18:28 vlad left 18:37 abraxxa left 18:52 abraxxa joined 18:55 vlad__ joined 18:59 vlad_ left 19:21 vlad__ left 20:04 zara joined 20:06 abraxxa left 20:15 zara left 20:18 zara joined, zara left 20:24 vrurg_ joined 20:26 vrurg left 20:35 vrurg_ is now known as vrurg 20:39 jpn joined 21:46 jpn left 22:14 Sgeo joined 23:34 sena_kun left