This channel is intended for people just starting with the Raku Programming Language ( Logs are available at
Set by lizmat on 8 June 2022.
05:13 systems_ joined
shad.ow /[^\s\d.]/ how can i comb with this regex in raku? 06:07
it doesn't seem to do what i expect it to do
ah got it 06:10
/<-[\d.]>/ 06:11
07:15 hexology left, hexology joined 08:12 systems_ left
nemokosch did you deliberately remove \s, by the way? 11:07
shad.ow yeah turns out it wasn't in the input 15:51
perl my @lines = "input.txt".IO.lines; my %gears; for @lines.kv -> $j, $line { for $line.comb(/<-[\d.]>/, match => True) { %gears{$_.from + $j * i} = []; } } for @lines.kv -> $j, $line { for $line.comb(/\d+/, match => True) { for ($_.from - 1)..($ -> $y { for ($j - 1)..($j + 1) -> $x { %gears{$y + $x * i}.append(+$_) if %gears{$y + $x * i}:exists; } } } } say
(gather %gears.values.deepmap(*.take)).sum; say> $ns { $ns.elems == 2 ?? $ns[0] * $ns[1] !! 0 }).sum;
any suggestions to improve this code ?
either making it more idiomatic or concise
nemokosch match => True might read better as :match 15:55
$_.from reads better as just .from
It's good to know that the hash is indexed by strings, even if you supply them as numbers 15:57
Could you explain why you needed that gather-deepmap-take? 15:59
fridge777 whats the operator for concatenating two lists? im trying to flatten a list of lists but the elements are lists too and i dont want to flatten those... 16:10
lizmat m: my @a = 1..5; my @b = "a" .. "e"; @a.append(@b); dd @a # fridge777 like so? 16:14
camelia Array @a = [1, 2, 3, 4, 5, "a", "b", "c", "d", "e"]
fridge777 no like for lists
ok i just found out about the slip operator
still a bit odd though 16:15
thanks i can use this
.vushu @antononcube so as I understand you just wan't to render example wise: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR" ? 16:36
17:29 kjp left 18:46 MasterDuke joined
antononcube Sounds good. 🙂 19:23
.vushu @antononcube cool I’m making the chessboard renderer in a more rakuish way. 😊 19:58
antononcube Hmm… I will try to make a Jupyter notebook that shows how it can be used. 20:09
20:46 kjp joined
sharparam so with 'file.txt'.IO.lines(:!chomp), that correctly preserves newlines when i read a file, but the same doesn't seem to work with just lines(:!chomp) to read from $*ARGFILES? so how would one go about achieving that? 22:39
lizmat If that doesn't work, it's a bug 22:41
it looks like indeed 22:42
sharparam bummer, what's the correct place for reporting that 22:43
nemokosch does it work with $*ARGFILES.lines(:!chomp) by the way? 22:45
lizmat nope, investigatinng
sharparam same issue when doing that 22:46
nemokosch ohh
lizmat yeah, it looks like $*ARGFILES is an instantiated IO::Handle, with $!chomp set to True 22:47
nemokosch seems like the underlying IO::Handle lines method doesn't even handle it 22:48
khm-khm, methods just consuming named arguments...
lizmat yup.. please make an issue for it, I will look at it tomorrow
22:48 sdomi left 22:49 sdomi joined
nemokosch it's normally the opening step that would handle the chomping 22:49
but if you are given a file handle directly, there is no opening...
sharparam yeah, i tried finding which is the proper issue tracker but not readily finding it 22:51
sharparam ty
lizmat no, thank you for noticing and reporting!
sharparam (not sure if discord reactions bridge to irc?) 22:52
nemokosch perhaps not
anyway, this seems rather simple to fix 22:56
just gotta make sure the named arguments are kept and properly saved in the method call
sharparam submitted: 22:58
lizmat sharparam++