🦋 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.
ToddAndmargo hi all! Is there a way so shorted `if $x ea "a" || $x= "b" || $x eq "c"`? Is there a way to say $x just once? 01:08
tobs ToddAndmargo: assuming "ea" and "=" both should be "eq", it's called a Junction
if $x eq "a" | "b" | "c" 01:09
ToddAndmargo ea was a booboo
tobs where the | has lower precedence than the eq
cf. docs.raku.org/type/Junction
ToddAndmargo Perfect! Thank you! `if $x eq "a" | "b" | "abc" {say "yes"}else{say "no"};` 01:10
ToddAndmargo I am getting greedy here. Is there a way put put the `"a" | "b" | "abc" ` into an array? 01:33
timotimo yes, you can use the "any" sub or the ".any" method on the array to construct the Junction you want 01:42
m: my @choices = "a", "b", "abc"; for "a", "aa", "aaa", "b", "bb", "bbb", "aba", "abc" { say $_, " ", $_ eq @choices.any } 01:43
camelia a any(True, False, False)
aa any(False, False, False)
aaa any(False, False, False)
b any(False, True, False)
bb any(False, False, False)
bbb any(False, False, False)
aba any(False, False, False)
abc any(False, False, True…
timotimo ah
printing the junction doesn't give you just the true/false
so you want a "so" if you're not using an if/else
m: my @choices = "a", "b", "abc"; for "a", "aa", "aaa", "b", "bb", "bbb", "aba", "abc" { say $_, " ", so $_ eq @choices.any }
camelia a True
aa False
aaa False
b True
bb False
bbb False
aba False
abc True
ToddAndmargo Hi Timo, thank you. 01:44
Okay, now I know I am pushing it. Can anyone point me to an example of a GTK information pop up with a time out feature? Or similar? 01:47
ToddAndmargo i will post it over on the mailing list 02:02
Thank you for all the help!
byebye
suman m: my @vector = (1,2,3); say @vector.WHAT; sub incrementMut(@vec) {return @vec.map: * + 1}; say incrementMut(@vector).WHAT; say @vector.WHAT; 09:03
camelia (Array)
(Seq)
(Array)
suman I passed Array to a function but it returns Seq.
Is it expected? 09:04
why changed the type?
m: my @vector = (1,2,3); say @vector.WHAT; sub incrementMut(@vec) {return @vec.map: * + 1}; say incrementMut(@vector).WHAT; say @vector;say incrementMut(@vector) 09:06
camelia (Array)
(Seq)
[1 2 3]
(2 3 4)
timotimo suman: the return value of the map method is a Se; map is lazy 09:09
MasterDuke m: my @vector = (1,2,3); say @vector.WHAT; sub incrementMut(@vec) {return eager @vec.map: * + 1}; say incrementMut(@vector).WHAT; say @vector;say incrementMut(@vector)
camelia (Array)
(List)
[1 2 3]
(2 3 4)
suman m: my @vector = (1,2,3); say @vector.WHAT; sub incrementMut(@vec) {return (@vec.map: * + 1).Array}; say incrementMut(@vector).WHAT; say @vector;say incrementMut(@vector) 09:11
camelia (Array)
(Array)
[1 2 3]
[2 3 4]
MasterDuke m: my @vector = (1,2,3); say @vector.WHAT; sub incrementMut(@vec) {return @ = @vec.map: * + 1}; say incrementMut(@vector).WHAT; say @vector;say incrementMut(@vector) 09:16
camelia (Array)
(Array)
[1 2 3]
[2 3 4]
suman MasterDuke Is it possible to pass array as argument and mutate the array after function is applied? 09:27
m: my @vector = (1,2,3); sub incrementMut(@vec) {return @ = @vec.map: * + 1}; say incrementMut(& @vector); say @vector;
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in argument list; couldn't find final ')' (corresponding starter was at line 1)
at <tmp>:1
------> 3@ = @vec.map: * + 1}; say incrementMut(&7⏏5 @vector); say @vector;…
suman m: my @vector = (1,2,3); sub incrementMut(@vec) {return @ = @vec.map: * + 1}; say incrementMut(&@vector); say @vector; 09:28
camelia [2 3 4]
[1 2 3]
suman original array is not mutated 09:29
MasterDuke m: my @vector = (1,2,3); say @vector.WHAT; sub incrementMut(@vec) {.++ for @vec}; incrementMut(@vector); say @vector; 09:30
camelia (Array)
[2 3 4]
timotimo g 09:57
raku-bridge <tmtvl> That's odd, the perl-bridge bot is posting everything twice here in Discord. 11:18
raku-bridge4 <tmtvl> That's odd, the perl-bridge bot is posting everything twice here in Discord.
tadzik looks like there's two bots, since they also posted your message twice on IRC 11:21
lizmat raku-bridge and raku-bridge4 on this side 11:23
El_Che ipv6 and ipv4?
whois raku-bridge4
tadzik probably a "I'll add 4 to my nick because the regular one is taken" bot instance 11:26
Geth_ ¦ old-issue-tracker: lizmat assigned to jnthn Issue EVAL not working with custom circumfixes,terms, etc github.com/Raku/old-issue-tracker/issues/4797 11:50
SmokeMachine (sorry, I just saw this message wasn't sent yesterday) lizmat: and trying to figure out what would be good a syntax to use them
lizmat SmokeMachine: lost context there
SmokeMachine lizmat: you asked me why I was playing with that assignment on immutable data structure's field returning a new structure. I'd answered that I was studying about functional data structures and that message that didn't go out (many different verb tenses here, sorry, probably everything is wrong) 11:54
lizmat ah, ok, :-)
SmokeMachine lizmat: do you think there is a good syntax for that? 11:55
lizmat assignment with functional data structures feels like it has a paradigm impedance 11:57
aka. it feels wrong :-)
SmokeMachine but isn't it almost equivalent to `my $new-ids = $ids.some-field("new value")` 12:01
lizmat almost, but maybe better: my $new-ids := $ids.some-field("new value") 12:05
aka, not having mutable containers
SmokeMachine `($new-istash, $value) = $istash.pop` is also a syntax I was trying to find a better way 12:09
lizmat $new-stash := $stash.pop(my $value) ? 12:11
SmokeMachine you mean `method pop($value is rw)`? 12:12
lizmat yup ?
SmokeMachine maybe the opposite? `$ids.some-field(my $new-ids, "new value")` `my $value = $istash.pop(my $new-istash)` and all "mutating" methods would receive it? 12:15
lizmat that'd be also a way :-) 12:16
brb&
sarna hello, I want to copy a file and append something to the name. how would I go about it? I'm stuck at "file".IO.copy: "file.bak" 12:43
I'd like to do something like `.copy: * ~ ".bak"` if you know what I mean
moritz sarna: sub copy-with-extension($name, $extension) { $name.IO.copy("$name.$extension) } 12:49
sarna moritz: I have this as an one-liner now, I just repeat `@*ARGS[0]` twice. I think it's still lower overhead than creating a sub 12:49
I just thought there'd be some magical, more raku-ish way to do it 12:50
jnthn .IO.copy("$_.bak") given @*ARGS[0] 12:52
moritz of course, unpacking @*ARGS is not very elegant. A sub MAIN($fn) { ... } reduces that clutter
sarna oh my, thanks jnthn! 12:53
also thanks moritz of course :D
I'd use MAIN if it was something bigger, but it's literally 33 characters on one line now :) 12:54
raku is such a nice refresher after doing stuff in python for a while! 12:55
suman Can a ternary expression be applied to map function? 13:10
Example:
m: my @arr = [1, 2, 3, 5]; say @arr.map: * < 2 ?? 1 !! 2
camelia Cannot map a Array using '1'
Did a * (Whatever) get absorbed by a list?
in block <unit> at <tmp> line 1
jnthn m: my @arr = [1, 2, 3, 5]; say @arr.map: { $_ < 2 ?? 1 !! 2 } 13:11
camelia (1 2 2 2)
cpan-raku New module released to CPAN! Algorithm::AhoCorasick (0.0.12) by 03TITSUKI 13:15
cpan-raku_ New module released to CPAN! Algorithm::AhoCorasick (0.0.12) by 03TITSUKI
lizmat suman: you can, but not with a WhateverCode 13:16
tyil[m] looks like we have 2 cpan-raku bot instances
suman lizmat got the help from jnthn thank you 13:22
sarna can I somehow feed `Date.new` strings that are not ISO 8601? 13:26
I tried with formatter, but that's only for printing the date after creating it :/
moritz no 13:47
you have to wrap it with your own parser
sarna it's european dates, so I just did the ol split and reverse 13:53
lizmat sarna: so "dd-mm-yyyy" ? 13:58
sarna lizmat: yep! "dd.mm.yyyy", to be exact
`$date.split('.').reverse.join('-')` 13:59
lizmat m: dd Date.new(|"04.06.2020".split(".").reverse) # faster by slipping 14:01
camelia Date.new(2020,6,4)
sarna oh wow, thanks! 14:05
[Coke] any faster with single quotes instead of double? :) 14:10
jnthn Only at parse time, no difference at runtime :) 14:11
[Coke] I am old school and try to use non-interpolating quotes whenever possible, possibly due to a code review in like 1996 or so. 14:12
moritz also, Perl Best Practice :D 14:14
sarna non-interpolating ones are 'these', right? 14:15
lizmat fwiw, in one-liners I usually try these things out and then I need to use "" rather than '' to prevent shell escaping issues 14:16
jnthn Then on Windows it's the opposite way around...argh :) 14:17
When I'm thinking, I do q/.../ or qq/.../ or similar instead of the quotes, but it ain't in the muscle memory yet. 14:18
sarna oh damn
m: say so "foo".contains: ("O", "x").any, :i
camelia True
sarna is this.. good style? not-so-horrible style? 14:19
chloekek 「」 and qq「」 for extra fancy fancy 🎀
lizmat m: ay so "foo".contains: "O" | "x", :i 14:20
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
ay used at line 1
lizmat m: say so "foo".contains: "O" | "x", :i 14:20
camelia True
lizmat sarna: unless you have your alternates in an array or so 14:21
sarna lizmat: no I make a literal for that. yours is more readable, thanks!
masak ahoy, #raku 14:50
tadzik ahoy! o
masak I used to do '' strings as much as possible. now I do "" strings as much as possible :)
what can I say. I contain multitudes.
my pet reason for going with "" strings is that English text tends to contain apostrophes, which I then don't (<--see?) have to escape 14:51
& 14:52
tadzik you can also switch to “proper quotes” :P
there's also a proper apostrophe in there somethere...
‘oh here’
m: say 'isn’t it nice' 14:53
camelia isn’t it nice
tadzik that makes it “fun” for people reading your code later :P
[Coke] :) 14:57
Dwarf Hello! I'm watching paint dry aka watching Raku get compiled on ARM64, but was met with the following message: "JIT isn't supported on aarch64-linux-gnu-thread-multi yet." - It was my understanding that it did, in a way? 15:27
lizmat Dwarf: no, JIT is not supported on ARM, but all of the other optimizations *are* afaik 15:32
so, spesh, inlining, static opts
Dwarf Ah I must've misunderstood then 15:33
That's a shame!
lizmat it will become an even bigger shame for the future when Apple switches back to Arm
[Coke] was the blocker time (versus demand) or lack of hardware, or... 15:34
lizmat well, I don't know, brrt should know :-) 15:36
[Coke] I wonder if there's a problem solving or rakudo ticket for it. 15:38
in any case, I bet you'll start working on it when you get a new mac. :)
jnthn I think it's mostly people with the correct combo of time and skills to do it 15:41
(Or patience to learn a lot of stuff. :)) 15:42
Dwarf compiling src/jit/stub.o 15:43
Huh. I guess it still compiles jit stuff
lizmat Dwarf: doubt it, since the JIT can only produce Intel opcodes 15:45
jnthn I think stub.o is the "we don't have a JIT" thing 15:47
Probably just a "do we have JIT" function returning false, or some such
Dwarf That'd make a lot of sense, it was the only file mentioning JIT during the compile
[Coke] yah, lots of return NULL; return 0; 15:52
jdv79 [Coke]: a CR in 96 huh? that's a long time ago. 15:53
was that perl 5.0? 15:54
[Coke] nope, java, tcl. 15:56
I think the boss was also trying to roll out Modula-3
also lots of CORBA 15:57
jdv79 oof
sounds like fun times 16:01
[Coke] I was also working at Enron at the time! 16:12
tbrowder hi 16:13
rbt Does anyone have opinions on how do() should work for DBIish? Opinions requested. 16:14
github.com/raku-community-modules/...issues/185
tbrowder is there any way (without a multi) to have a sub signature taking either an array, list, or string with a sigil of either $ or @? 16:15
any array or list input may have a @ or $ sigil but a str would have a $.
rbt Slurping gets pretty close, with the side effect that you flatten bits. 16:18
tbrowder and after the single param as above, regular named but non-mandatory params would need to be allowed
rbt tbrowder: Does this do it? foo(\param, $param2) 16:23
tbrowder maybe, i'll try that--i've never used such an arg name before (never thought i would have a use case)--this may do the trick--thanks! 16:25
before i try that, i need to be more specific. the caller may use @ or $ for an array. i'm trying to avoid a multi if i can 16:28
tbrowder rbt: i gave up and so far an easy multi has taken care of the problem, thanks, though. 16:37
[Coke] can I ask why you were trying to avoid a multi/ 16:51
?
tbrowder laziness... 17:04
tbrowder actually i was trying to change two subs into one but i later decided that a correct solution is preferred at the moment. 17:06
Dwarf raku raku-diceroll/dice.p6 2.32s user 0.11s system 153% cpu 1.584 total 17:54
Well the compiling worked, not sure I'm happy about the speed gains though 17:55
timotimo this is a hand-compiled moarvm on an arm system? compared to what? 17:58
Dwarf The old 2019 version ubuntu ships
timotimo OK
Dwarf that's uh.... 2019.11-4 17:59
timotimo is the dice.p6 code available on line?
Dwarf Yep!
Dwarf It's my first thing written in raku though so... it could be better probably. bcome.nl/git/raku-diceroll.git/tree/dice.p6 18:00
timotimo yeah, grammars aren't the fastest thing we have 18:01
Dwarf I knew the risks I was taking
timotimo does it get much faster the second time it runs? how about timing raku -e '' to get a rough estimate of what "doing nothing" costs?
Dwarf I'll give it a shot!
raku -e '' 0.71s user 0.07s system 118% cpu 0.658 total 18:02
timotimo that's relatively slow, sadly
Dwarf Question: disk speed potentially affects this right?
timotimo yeah, but if you have enough ram, linux would normally keep the files around for faster retrieval 18:03
so the second time you run it should not have to pay for disk access
Dwarf Though raku -e '' shouldn't suffer from disk read speeds I suppose
timotimo i think disk wait times would show up mostly as "system" time, too 18:04
Dwarf SD cards are the worst thing about modern ARM devices 18:05
cpan-raku_ New module released to CPAN! Grammar::DiceRolls (0.2.0) by 03TYIL 18:30
Manifest0 My raku script just died with a SIGSEGV (Address boundary error), which generated a core dump (512MB). Is anybody interested in that? I also have the strace output.... 21:50
MasterDuke can you put it somewhere to download? 21:51
Manifest0 yeah sure. 21:52
MasterDuke btw, how did you get your raku? compiled it yourself? 21:53
Manifest0 let me find a place to upload the file
MasterDuke i've used mozilla's service before
Manifest0 yes. Compiled my self. I used the PKGBUILD from aur
can you send me the link? 21:54
MasterDuke ah. can you easily repro it? because if so, then it'd be good to re-compile moarvm with debug symbols, it'll make the backtraces more useful 21:54
send.firefox.com
Manifest0 yes, I can reproduce it with some easiness. 21:55
what are the flags to enable the debug symbols? 21:56
aur.archlinux.org/cgit/aur.git/tre...rakudo-git
MasterDuke it's the moarvm package you'll need to rebuild. add `--debug=3` to the `perl Configure.pl` call 21:59
Manifest0 unfortunately send.firefox.com only allows 1 download or 24h. send.firefox.com/download/17446092...pFgg7dL1kg 22:02
MasterDuke: I will do that tomorrow, if you don't mind. It's already late here.
MasterDuke np
Manifest0 thx 22:03
RaycatWhoDat what is happening. 22:39
So many people joining.
Grinnz irccloud hiccup 22:40
RaycatWhoDat ah 22:40
RaycatWhoDat So, in Raku documentation, when you see something like `Int:D`, what does that mean? 22:44
timotimo it means the parameter is required to be an int, or derived from int, and also definite (not a type object) 22:46
RaycatWhoDat Interesting. 22:47
Where could I read up on that?
timotimo "type smiley"
RaycatWhoDat Got it. Thanks again. 22:48
timotimo no prob 22:49
also when it looks like Int:D: with the extra : that's the invocant marker
timotimo where it means that the thing a method is called on is restricted to Int:D 22:50
can also have a name in between
or only a name without a type constraint
tobs the invocant frowny 22:51
timotimo well, either it's :U: which i guess is a very happy cry?
or a :D: where it could be a crying scream
RaycatWhoDat Schrodinger's Smiley 22:54
timotimo that's probably :_: 23:01
no i guess everybody knows that one