🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
ab5tract anyone else here using Raku on Windows? I'm surprised to be experiencing garbled text a la "Welcome to 𝐑𝐚𝐤𝐮𝐝𝐨™ v2020.10." 00:05
tbrowder is there any built-in method i'm missing? 00:08
guifa tbrowder: I don’t think there is a better built in method 00:10
guifa2 ab5tract: that's because the Windows terminal doesnt support higher plane Unicode I think 00:40
timotimo you need to use "chcp" with some special value to get unicode in the terminal
ab5tract timotimo, guifa2 -- geez, that's unfortunate... 00:41
guifa2 ab5tract: it's a thing to help with trademarky stuff rigth now. It might not be permanent 00:42
leont «chcp 65001» may help
ab5tract leont: that does seem to help! 00:43
at least with the TM ...
and also with the output from regex matches.. thanks for the tip! 00:44
huh... doesn't help in Powershell ISE but does help in the Terminus term emulator that I usually use.. 00:50
pretty crazy to see Unicode issues in 2020, but whatevs, it's "solved" :) 00:51
coldpress is there a shorter way to extract the first elements of each list, in a list of lists? 07:11
m: map *[0], (0..3).combinations(2)
camelia ( no output )
coldpress m: say do map *[0], (0..3).combinations(2)
camelia (0 0 0 1 1 2)
moon-child coldpress: not shorter, but I would probably say 07:14
m: print (0..3).combinations(2).map(*.head)
camelia 0 0 0 1 1 2
coldpress moon-child: that's fine, but I'm looking to extract other indexes as well, like: 07:17
m: say do map *[2], (0..5).combinations(3) 07:18
camelia (2 3 4 5 3 4 5 4 5 5 3 4 5 4 5 5 4 5 5 5)
moon-child I don't entirely follow. map *[0 .. k], @a will give you the first k elements of each list contained in @a, but I don't think that's what you're looking for 07:20
(or perhaps flat map *[0 .. k], @a) 07:21
guifa2 coldpress: @foo[*;0] 08:47
guifa2 m: my @a = 1,2,3; my @b = 10,20,30; my @c = 100,200,300; my @d = @a, @b, @c; say @d[*;0] 08:47
camelia (1 10 100)
guifa2 Or for your example: 08:49
m: say (0..3).combinations(2)[*;0]
camelia (0 0 0 1 1 2)
guifa2 You can also use >> inside of your method call, that will distribute the subsequent call to each item in the former (functionally it's very similar to map, but there are some differences)
m: say (0..3).combinations(2)>>[0] 08:50
camelia (0 0 0 1 1 2)
holyghost guifa2 : that's nice 09:59
JJAtria[m] Are there any recent-ish examples out there of using NativeCall with C++ classes, etc? 10:06
Found this from 2016, but I'm not sure if things have changed significantly since then: hoelz.ro/blog/binding-to-cpp-with-nativecall
And this section is a bit scant: docs.raku.org/language/nativecall#C++_support 10:07
notandinus oof raku is driving me mad 11:42
m: my @set = 1, 2, 3; my @tmp = 0 .. @set.elems - 1; @tmp = @tmp.reverse; while shift @tmp -> $idx_1 { for @tmp -> $idx_2 { say "$idx_1 $idx_2" } } 11:43
camelia 2 1
2 0
1 0
notandinus m: my @set = 1, 2, 3; my @tmp = 0 .. @set.elems - 1; while shift @tmp -> $idx_1 { for @tmp -> $idx_2 { say "$idx_1 $idx_2" } }
camelia ( no output )
notandinus why does the first one work and second one doesnt?
notandinus paste.debian.net/hidden/c23f3a36/ - here is prettier version 11:44
if you remove line 4 it doesn;t work
is this a bug?
lizmat the first shift of @tmp yields a 0 if @tmp is not reversed. This is false, so the outer loop will never fire 11:47
so ENOTACOREBUG :-)
notandinus oh 11:48
lizmat notandinus ^^
notandinus oof i've been using it everywhere
what's the correct way of doigng this ?
lizmat define "this" :) 11:50
notandinus i want to loop over @tmp while pop'ng it 11:51
lizmat while @tmp { my $popped = @tmp.pop } 11:51
notandinus i see, can i ask `while' to not focus on pop'ed value & work with if `shift` was successful? 11:53
lizmat in this case, the while just looks at whether @tmp has any elements in it 11:54
so I'm not sure how shift or pop comes into that
or what you're trying to achieve
notandinus i see, yeah your code will fix it
what would be the direct translation of this perl code: 11:55
while (my $pop = pop @tmp) { }
lizmat for @tmp.reverse -> $pop { 11:56
lizmat well, that wouldn't destroy your @tmp 11:56
otherwise:
if you know there are only true values in @tmp (which in your case, there weren't) 11:57
you could do:
while @tmp && @tmp.pop -> $pop { 11:58
notandinus i see, 12:00
actually that while @tmp { my $popped = @tmp.pop } doesnt fix it
what i want to do is, combinations (nested for) but my operation is addition so a + b == b + a, that is why i want to eliminate the value as i go on 12:01
that code does this: paste.debian.net/hidden/0f878f78/ 12:02
ok wait, ah sorry, i should use $popped as $idx_1 12:03
thanks, that fixes it 12:05
lizmat m: dd (^10).combinations(2).unique: :as(&sum) # something like this ? 12:09
camelia ((0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (1, 9), (2, 9), (3, 9), (4, 9), (5, 9), (6, 9), (7, 9), (8, 9)).Seq
notandinus lizmat: yeah that's what i wanted, i should've read about combinations, i didn't know of unique method 12:14
i'll read the docs,t hanks 12:15
lizmat yw :-)
notandinus lizmat: i think .unique is not required 12:19
m: say (^3).combinations(2).unique
camelia ((0 1) (0 2) (1 2))
notandinus m: say (^3).combinations(2)
camelia ((0 1) (0 2) (1 2))
notandinus looks like combinations does it by default 12:20
lizmat yeah, but you wanted uniqueness on the sum of the values ?
m: say (^4).combinations(2) # note that both (0 3) and (1 2) will produce 3 as sum ? 12:21
camelia ((0 1) (0 2) (0 3) (1 2) (1 3) (2 3))
notandinus ah, sorry for misunderstanding, i wanted what combinations does by default 12:22
lizmat ok, then you're good with just combinations :-)
notandinus what i meant was both (0 1) and (1 0) will produce same sum
i mean the index,
lizmat ok
notandinus also, shouldn't this default behaviour of combinations be a bug? 12:23
notandinus because 12:23
m: say (^3).combinations(2).unique 12:24
camelia ((0 1) (0 2) (1 2))
notandinus should include (2 2) right ?
and also (1 0) (2 0)
is it expected behaviour? 12:25
lizmat m: say <a b c>.combinations(2) # maybe not using numbers makes it easier 12:26
camelia ((a b) (a c) (b c))
lizmat you're *combining*
(a a) cannot happen, because "a" only occurs once 12:27
m: say <a a b c>.combinations(2)
camelia ((a a) (a b) (a c) (a b) (a c) (b c))
lizmat note that now you have two "(a b)" and "(a c)" because there are two "a"\s
notandinus oh right 12:33
what i was thinking of is permutations right?
oof i'm already starting to forget these things
lizmat well, maybe *I* led you astray here 12:34
notandinus no, i had this discussion before too with someone else 12:35
i didn't understand what they were saying so i gave up, it was right here in #raku
thanks for fixing this 12:36
lizmat ok, well, I don't really backlog here anymore.. there's just too much to backlog :-)
notandinus hah yeah, its quite idle when i'm online though 12:37
might be active when i'm sleeping
tbrowder jmerelo (or anyone): when running Pod::To:HTML how can i eliminate the toc 14:04
tbrowder i like everything else but i don't see how to automagically eliminate it. 14:08
MasterDuke coldpress: thanks, made those edits 14:12
leont What is generally considered a reasonable backwards compatibility policy in Raku. 14:14
I have the impression people in Raku tend to run relatively recent versions, but I'm not sure (especialyl not wrt distro packaged versions)
vrurg leont: we don't break it except for some bugs. Roast and ecosystem testing ensures that no major breaks happen. 14:18
leont I should be more specific: how backwards compatible should I be in my *modules* 14:19
vrurg This is harder to say. I'd say that best if you make them work with distros packages. But how much do they lag behind – I don't know. A year old rakudo release looks reasonable to me. 14:22
leont .rakumod is an obvious case of "only supported for about a year", but I also have some code for working with older version of raku in one of my modules 14:25
coldpress guifa2: nice, thanks for the two ways of distributing calls over arrays 14:39
tellable6 coldpress, I'll pass your message to guifa2
vrurg leont: to my view, if somebody is happy with really old version of compiler they could be ok with older versions of modules. 14:40
leont Apparently the version shipped with ubuntu LTS has .rakumod support, that does make things a bit easier 14:43
RaycatWhoDat Quick question: what's the state of game development in Raku? Is it still "make-bindings-to-SDL2-and-roll-everything-yourself"? 15:50
jmerelo RaycatWhoDat: kinda, yes. There's SDL" and SDL::raw. 15:51
RaycatWhoDat Is it a similar story for GUI development? 15:53
dakkar GUI is a bit better modules.raku.org/search/?q=gnome 16:16
you can use nearly all of GTK3
(disclaimer: I haven't tried, yet)
codesections does anyone happen to know the implementation details of Raku Arrays enough to say whether there's a performance reason to use them as a queue via `unshift` and `pop` versus `push` and `shift`? 16:21
dakkar run a benchmark and see what happens? 16:22
codesections (that is, whether the direction matters)
dakkar: fair :D
dakkar it may well change between different releases
(which is all a long winded way of saying "I don't know" 😜)
codesections well, I'm not really interested in *micro* optimizations of the sort that change super frequently 16:24
dakkar I've written this: `use Benchy; my @front = ^100; my @back = ^100; b 2_000_000, { @front.unshift(1); @front.pop() }, { @back.push(1); @back.shift() };` 16:32
it doesn't give any reliable results
as in, different runs give very different times
2M operations take <½s on my machine
dakkar codesections: I've checked with three different benchmark modules, the answer is: if there is a difference, it's too small to measure, pick whichever style looks better for you 16:40
codesections Thanks. (I didn't know about benchy -- I'll have to check that out) 16:42
dakkar I just searched "benchmark" on modules.raku.org
then used all three results ☺
codesections haha, fair enough :D 16:43
I've always just used `now - INIT now` 16:44
dakkar that has a few problems when you want to compare different implementations in a single run 16:45
but it's good enough for a first approximation 16:46
codesections agreed. Which is as far as I've gone 16:47
guifa2 grr, I wish array slices could be used as left hands in assignment 17:34
tellable6 2020-12-09T14:39:57Z #raku <coldpress> guifa2: nice, thanks for the two ways of distributing calls over arrays
[Coke] m: my @a = 1..10; @a[1,2,3]=4,5,6; dd @a 17:39
camelia Array @a = [1, 4, 5, 6, 5, 6, 7, 8, 9, 10]
[Coke] guifa2: ^^ ??
guifa2 [Coke]: I should have been more specific, I wanted to do 17:40
@a[3,4,5] = 5 17:41
--> [1,2,3,5,5,5,6…]
guifa2 but >>= doesn't work :-( 17:42
I can use @foo[*] = $bar xx Inf though it just feels clunkier 17:43
MasterDuke codesections: github.com/MoarVM/MoarVM/pull/1392 is likely relevant 17:44
codesections guifa2: is the clunkier alternative this: 17:46
m: my @a = 1..10; @a[3, 4, 5] = 5 xx *; say @a
camelia [1 2 3 5 5 5 7 8 9 10]
codesections MasterDuke: thanks 17:48
guifa2 codesections: I forget about the star sometimes haha 17:49
codesections :D or ∞, though * seems clearer here, IMO 17:51
guifa2 although actually dangit 17:55
That won't work for me
I need to swap out the key name at one level of a nested hash 17:56
there's gotta be a simpler way
tbrowder .tell jmerelo my advent article is ready for publishing and it's here <github.com/tbrowder/advent2020/blo...t.html> 17:57
tellable6 tbrowder, I'll pass your message to jmerelo
tbrowder .tell jmerelo i'll try to put it on the raku-advent.blog site but i'm now having much luck with it so far 17:58
tellable6 tbrowder, I'll pass your message to jmerelo
guifa2 .<new> = .<old> if .<old> for %a{*;*} # this will work since the old key name sticking around is okay 18:01
.<new> = .<old>:delete if .<old> for %a{*;*} # even better! 18:05
tbrowder .tell jmerelo it's on the advent site, bit styling doesn't look great, bummer
tellable6 tbrowder, I'll pass your message to jmerelo
jmerelo tbrowder: ack. I'll check it out. Thanks! 18:21
tellable6 2020-12-09T17:57:39Z #raku <tbrowder> jmerelo my advent article is ready for publishing and it's here <github.com/tbrowder/advent2020/blo...t.html>
2020-12-09T17:58:57Z #raku <tbrowder> jmerelo i'll try to put it on the raku-advent.blog site but i'm now having much luck with it so far
2020-12-09T18:05:10Z #raku <tbrowder> jmerelo it's on the advent site, bit styling doesn't look great, bummer
cydf Hi all 18:44
guifa2 waves at cydf 18:46
cydf There used to be a thing called 'p6doc' before... what would that be now? There's no 'rakudoc' in my install from rakubrew
moritz use docs.raku.org/ 18:48
cydf And how do I get the docs from an installed module? Or do I have to find those on-line, too? 18:51
moritz ha, good question 18:52
cydf I guess that means there's no good answer.... 18:53
leont There's raku --doc, but that expects a file not a module name 18:55
moritz I'm not omniscient
jjmerelo There's actually rakudoc 18:56
You need to install it on top of the documentation.
But moritz's answer is actually the best thing. Use them online. 18:57
cydf Where would I find this mythical rakudoc? Doesn't seem part of the ruke distribution... 18:58
ruke/raku
jjmerelo cydf: zef install rakudoc, probably 19:01
Let me check
But, again, the web which you can also build yourself is your best bet. rakudoc is not thoroughly checked, and it's not even called rakudoc... I haven't been able to find it 19:02
github.com/Raku/rakudoc Not sure why it's not been released... Probably because I had to check it before we did, and we didn't 19:03
cydf: there's a pre-built repo which you can just download here github.com/rakudocs/rakudocs.github.io
leont Yeah, having it in the module repository would be helpful 19:05
cydf OK, thanks jjmerelo 19:06
jjmerelo cydf: sure :-) 19:10
SmokeMachine m: my @a; @a = 5 xx *; say @a 20:04
camelia [...]
SmokeMachine m: my @a; @a = 5 xx *; .say for @a 20:05
camelia (timeout)5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5…
SmokeMachine m: my @a; @a[<1 3 5 7 9>] = 5 xx *; .say for @a 20:09
camelia (Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
guifa2 SmokeMachine: or even 20:20
m: my @a; @a[1,3,5 ... *] = 5 xx *; .say for @a
camelia ( no output )
guifa2 glares at camelia
moritz m: my @a; @a[1,3,5 ... *] = 5 xx *; .say for @a.head(10) 20:29
camelia ( no output )
moritz m: my @a; @a[1,3,5 ... *] = 5 xx *; .say @a.head(10)
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3my @a; @a[1,3,5 ... *] = 5 xx *; .say7⏏5 @a.head(10)
expecting any of:
infix
infix stopper
statement end
st…
moritz m: my @a; @a[1,3,5 ... *] = 5 xx *; say @a.head(10)
camelia ()
guifa2 m: my @a; @a[1,3,5 ... 9999] = 5 xx *; .say for @a 20:31
camelia (Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5
(Any)
5…
guifa2 notes the limitation: must be a finite list
moritz would have prefered an error message to a silent non-action 20:39
MasterDuke yeah, that's interesting 20:46
grondilu SpaceX's second attempt imminent : www.youtube.com/watch?v=ap-BkkrRg-o 21:00
lizmat T-minus 3 minutes 21:01
moritz tenative T-0 now at 22:40 UTC 21:25
El_Che now 21:39
moritz in one hour, actually 21:43
El_Che that's why it doesn't move 21:44
:)
ggoebel how do you make a method or function signature that requires an array parameter to be an array of integers? 22:43
leont You can declare an Int @array, but that does something subtly different 22:44
It wants you to pass an Array[Int], not an Array that happens to contain Ints
So unless that array is the former, that won't help you
ggoebel can you use a where clause to constrict it to an array of int? And would that also allow an Array[Int]? 22:45
leont You can do that, yes
ggoebel what is the syntax for that... I'm reading docs.raku.org/type/Signature#index...ere_clause but not seeing it 22:46
thank you for your help leont++
leont sub foo(@array where all(@$_) ~~ Int) {} 22:47
Or better, sub foo(@array where $_.all ~~ Int) {} 22:48
ggoebel thank you! 22:50
lizmat well, that was interesting: hit the target with a little excess velocity :-) 23:03
leont Boom is bad? 23:21
lizmat well, flying something up to 12.5km by just rockets, then getting it back to within meters of the target, is quite the achievement already 23:31
after the smoke cleared, the message was "SN9 is up next" or something to that effect