🦋 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.
00:01 holli__ joined, gdonald joined 00:02 Doc_Holliwood left 00:04 Doc_Holliwood joined, Doc_Holliwould left 00:06 Doc_Holliwould joined 00:07 holli__ left
Nasrudin Matrix is also bridged here :) 00:08
00:09 holli__ joined 00:10 Doc_Holliwood left 00:11 softmoth joined 00:12 Doc_Holliwood joined 00:13 Doc_Holliwould left 00:15 Doc_Holliwould joined, skids left, holli__ left 00:18 holli__ joined, Doc_Holliwood left 00:20 uvb left 00:21 Doc_Holliwould left, Doc_Holliwood joined 00:23 Doc_Holliwould joined 00:24 holli__ left, AlexDani` joined
Nasrudin If I have something like class Foo { has &.runme; } 00:24
How could I constrain the assignment of runme to subroutines matching a specific signature?
guifa Nosrudin: how specific? 00:26
00:26 holli__ joined
Nasrudin Foo.new( runme => -> (Int $a, Str $b) { ... } ) 00:26
So i'd like to do the above
00:27 Doc_Holliwood left 00:28 AlexDaniel left 00:29 Doc_Holliwood joined, Doc_Holliwould left
guifa Nasrudin: I would use a subset 00:29
subset Foo of Callable where { … } 00:30
00:31 Doc_Holliwould joined
Nasrudin what do I put in the braces? 00:32
00:32 holli__ left
guifa Nasrudin: something to specify it. I’m not sure offhand the exact introspection for signatures 00:33
But for example, you can check arity quickly: where { .arity == 2 }
00:34 holli__ joined 00:35 Doc_Holliwood left
Nasrudin subset Foo of Sub where { .signature.ACCEPTS: \(Int, Str) }; 00:37
00:38 Doc_Holliwould left, Doc_Holliwood joined
Nasrudin That seems to work 00:38
Thanks, that was the missing piece I think :D 00:39
guifa Nice, I actually didn’t even think about using a signature literal
Nasrudin hey I'm too new to Raku ... that was AlexDaniel's suggestion
00:40 Doc_Holliwould joined
Nasrudin I just put 2 and 2 together 00:40
Your suggestion has the directness I want ... I actually have a "type" now that I can measure subroutines against
00:41 holli__ left 00:42 holli__ joined 00:43 Doc_Holliwood left 00:46 Doc_Holliwould left, Doc_Holliwood joined 00:48 Doc_Holliwould joined, holli__ left 00:51 holli__ joined, Doc_Holliwood left 00:53 Doc_Holliwood joined 00:54 Doc_Holliwould left 00:56 Doc_Holliwould joined 00:57 holli__ left 01:00 Doc_Holliwood left 01:02 Doc_Holliwould left 01:14 oddp left 01:24 daxim left 01:26 lucasb left 01:32 molaf left 01:35 ifarcas joined 01:36 Altai-man_ joined
guifa Nasrudin: there are some other options (making a role, for instance), depending on whether you expect adhoc callables or not 01:37
Nasrudin Can you elaborate? 01:38
01:39 sena_kun left 01:45 molaf joined 01:49 ShimmerFairy left 01:50 ShimmerFairy joined, MasterDuke left 01:56 Redfoxmoon left, Redfoxmoon_ joined 03:02 nativecallable6 left, statisfiable6 left, bloatable6 left, evalable6 left, benchable6 left, coverable6 left, shareable6 left, tellable6 left, greppable6 left, quotable6 left, sourceable6 left, committable6 left, releasable6 left, unicodable6 left, reportable6 left, bisectable6 left, squashable6 left, linkable6 left, notable6 left, committable6 joined, unicodable6 joined 03:03 coverable6 joined, greppable6 joined, quotable6 joined, shareable6 joined 03:04 linkable6 joined, squashable6 joined, notable6 joined, nativecallable6 joined, sourceable6 joined, releasable6 joined, reportable6 joined, bloatable6 joined 03:05 statisfiable6 joined, tellable6 joined, benchable6 joined, evalable6 joined, bisectable6 joined
guifa Nasrudin: subsets have to get checked on asssignment each time. If you made a role with a single ACCEPTS method appropriate signatured, it wouldn’t need to do all those checks. It’s just a case of multiple ways to do similar things 03:19
03:37 sena_kun joined 03:38 _jrjsmrtn left, Altai-man_ left 03:40 __jrjsmrtn__ joined, mowcat left 03:50 softmoth left 04:17 ifarcas is now known as farcas1982regreg 04:24 rainmanjam joined, KindTwo joined, KindOne left 04:29 KindTwo is now known as KindOne 04:31 softmoth joined 04:34 xinming left 04:35 xinming joined 05:18 stoned75 joined 05:22 xinming left, xinming joined 05:25 sauvin joined 05:29 wamba joined 05:36 Altai-man_ joined, leah2 left 05:38 sena_kun left 05:47 aborazmeh joined, aborazmeh left, aborazmeh joined
samebchase- Hi, I'm using the qqx construct to run shell commands. Is there a way in which I can just print/return the generated shell command so that I can inspect the generated output before running it. 05:56
05:56 leah2 joined
moritz my $command = "$your comand"; say $command; my $result = qqx/$command/; 05:58
samebchase-: ^^
samebchase- wow, thanks moritz! 06:00
06:03 leah2 left 06:09 leah2 joined 06:13 sjm_uk joined 06:34 xinming left, xinming joined 06:38 sarna joined 06:44 rindolf joined 06:45 brtastic joined 06:47 wamba left 07:04 abraxxa joined, finanalyst joined 07:05 abraxxa left 07:06 abraxxa joined 07:07 soursBot joined, abraxxa left, abraxxa joined 07:09 MasterDuke joined 07:19 hacktor joined, hacktor left 07:37 sena_kun joined 07:38 Altai-man_ left 07:39 dakkar joined 08:05 squashable6 left 08:07 rindolf left, squashable6 joined 08:12 rindolf joined 08:18 soursBot left 08:20 leont joined 08:22 soursBot joined 08:23 rindolf left 08:29 rindolf joined 08:33 patrickb joined 08:34 oddp joined, Redfoxmoon_ left, Redfoxmoon_ joined 08:35 Redfoxmoon_ is now known as Redfoxmoon 08:36 pecastro joined 08:38 abraxxa left, abraxxa joined 08:57 AlexDani` is now known as AlexDaniel, AlexDaniel left, AlexDaniel joined
AlexDaniel samebchase-: unless you're doing very heavy input validation your qqx code is probably incorrect 09:00
samebchase-: qqx doesn't do anything to prevent shell injection 09:01
lizmat clickbaits rakudoweekly.blog/2020/06/08/2020-...0-rakoons/ 09:09
[ptc] fell into the trap again! 09:10
09:10 soursBot left 09:13 soursBot joined 09:15 kensanata joined 09:19 Sgeo left 09:22 oddp left 09:26 oddp joined 09:35 JJMerelo joined 09:36 Altai-man_ joined 09:38 sena_kun left 09:39 xinming left 09:42 xinming joined
Geth_ doc: 754e41ea56 | (JJ Merelo)++ | doc/Language/functions.pod6
Add example of referring to operators

Including "generated" ones like XX, mentioned in #2632
09:51
linkable6 Link: docs.raku.org/language/functions
DOC#2632 [open]: github.com/Raku/doc/issues/2632 [Hacktoberfest][RFE][big][docs][good first issue][help wanted][new][⚠ Top Priority ⚠] Checklist for 6.d
09:57 wamba joined 10:05 farcas1982regreg left 10:08 ifarcas joined
finanalyst I'm trying to add a Windows environment to test a module that uses GTK. I haven't used Windows for a while. I have installed apveyor, but I'm not sure the tests have actually run 10:10
Any advice?
JJMerelo finanalyst check out other modules using AppVeyor, like doc 10:13
finanalyst not sure about how the actual windowing thing will work in a containerized environment, though
Geth_ ¦ problem-solving: lizmat assigned to jnthn Issue Managing the Raku project as it is Coming of Age github.com/Raku/problem-solving/issues/203
JJMerelo finanalyst basically you need to download using chocolatey or nuget the needed libraries, and then a rakudo star version compiled for Windows. 10:14
finanalyst JJMerelo: Thanks JJ. I have copied the apveyor test files from GTK::Simple. But the tests have an if statement that avoid contexts without windows 10:15
So the test suite seems to run, but I dont know if they do. 10:16
I'm told my module fails on Windows, so I'm trying to find out why. 10:17
10:18 Geth_ left, Geth joined
JJMerelo finanalyst ah, OK... I think you can test for different versions using Raku; also for different GTK versions. Try that. Or it might be something that has not been tested... 10:19
finanalyst JJMerelo: Other than GTK and the NativeCall needed to install GTK, the Module (Informative) is simple. I understand that GTK::Simple installs Ok on Windows, but not Informative. 10:20
JJMerelo finanalyst does it install in AppVeyor? So it's a problem with a specific Windows version? 10:21
El_Che hi jj 10:27
lizmat: can you link niner explanation of the 5-3-1 rule (github.com/Raku/problem-solving/is...633507296) in your great post (github.com/Raku/problem-solving/is...635299132) 10:33
it's a little difficult to follow without the link (or better: a very short one sentence explantion what that rule is) 10:34
lizmat El_Che: done
10:35 softmoth left 10:36 ifarcas left
El_Che this could be a summary of it: "when requesting a decision from your manager, describe the problem in 5 sentences, provide 3 solutions and 1 recommendation" 10:36
El_Che back to reading the ticket
finanalyst lizmat: I tried sending you an email on [email@hidden.address] . Hoping to get some help on Perl6-parser 10:37
El_Che githib
I like that
10:38 Black_Ribbon left
finanalyst shame-faced github 10:38
lizmat finanalyst: hmmm... that should have arrive, whether it'd be githib or github
El_Che githip
finanalyst lizmat: I rechecked. It was addressed to [email@hidden.address] Mistake was here 10:39
lizmat goes through the junk 10:40
finanalyst Oh my!! To be junked on my first email! Like - was it wot I said? :) 10:42
lizmat hehe... I have plenty of mails from yo, just not directly addressed at me :-)
lizmat typically gets 8K - 12K junk mail / month 10:43
and that's the ~20% that actually reaches my mailbox
finanalyst It was only a short message asking if it was a good place to send. Since you are here ... 10:44
lizmat finanalyst: could you try sending it liz at dijkmat.nl ?
finanalyst I'm trying to understand drorr's perl6-parser . But it's not passing a single test. The issue appears to be where you added a commit 10:45
lizmat finanalyst: do you know which commit ?
finanalyst looking
lizmat: commit on Jan 27, 2020. related to changing the name of the compiler. github.com/drforr/perl6-Perl6-Pars...42c40b262f 10:47
10:48 aborazmeh left
lizmat aha... 10:48
finanalyst But I'm not sure that it is your commit that broke the tests. I've not looked at the module before
I want to use pod6 files as a source for html files in a CMS. But invoking the whole raku compiler for each file is slow 10:49
So, I want to find a way to run multiple files through the parser, but instantiate the parser once 10:50
I probably don't need all of perl6-parser 10:51
lizmat hmmm.. simultaneously ?
10:51 xinming left
finanalyst no. iteratively would still be better than reinstantiating for every small pod file 10:52
i think
lizmat hmmm.. all tests pass for me on HEAD 10:53
finanalyst oh!
10:53 xinming joined
finanalyst I get: prove -vre 'raku -Ilib' 10:54
./t/00-class-hierarchy.t ......
1..1
Cannot call method 'defined' on a null object
in method parse at /home/richard/development/p6-parser/examples/../lib/Perl6/Parser.pm6 (Perl6::Parser) line 543
in method to-tree at /home/richard/development/p6-parser/examples/../lib/Perl6/Parser.pm6 (Perl6::Parser) line 584
in block <unit> at ./t/00-class-hierarchy.t line 18
This is inside a local copy of the git repo 10:55
lizmat weird, that passes for me 10:59
which version of raku are you on ? 11:00
finanalyst 2019.07.1 built on MoarVM version 2019.07.1
I was wondering if I'm out of date.
is there a way to update from a local terminal? 11:01
eg using zef
I mean update raku
El_Che finanalyst: what os do you run?
finanalyst ubuntu (actually pop!os) 11:02
El_Che I provide repos if you want, and there are also relocable tar.gz if you want a quick install: github.com/rakudo-pkg 11:03
11:03 JJMerelo left
finanalyst El Che: that link has just given me a 404 error 11:04
El_Che github.com/nxadm/rakudo-pkg
sorry
11:04 hacktor joined
El_Che that one 11:04
finanalyst That's the package I use 11:05
11:05 rbt left
El_Che so why are on an old rakudo? 11:05
11:05 rbt joined
finanalyst :) VERY VERY useful. But I haven't updated recent. Shame on me 11:05
El_Che did you pin the package?
ah ok
finanalyst 'pin the package' ??
El_Che you can pin packages on debian/ubuntu so they are not upgraded 11:06
finanalyst i'll check
don't think so
El_Che e.g. if you need a specific version or recent releases have problems: wiki.debian.org/AptConfiguration
package pinning does not happen accidently :)
you probably haven updated in a while :) 11:07
finanalyst oooooh dear. Seems I've missed ALOT of upgrades on lots of things. 11:08
El_Che maybe you updated and the repos are commented out?
finanalyst Not sure. I just ran `apt upgrade` and there are a gazillion upgrades. Not sure why this happened. 11:09
El_Che well if you're running 2019.07.1 there is probably a year of updates missing :) 11:10
finanalyst I know. :( :(
11:11 sftp left, sftp joined 11:13 soursBot left 11:14 Celelibi left
Roamer` BTW... I know I'm a bit paranoid and control-freak-ish sometimes, and I guess it might be too late already, but in such cases I usually do `apt install dpkg apt` first, and then I proceed with the actual upgrade 11:14
El_Che I probably do "apt-get update && apt-get -u dist-upgrade -y && apt-get auto=renove -y" daily on my laptop :) 11:18
Roamer` yeah, "in such cases" meant "other than my daily upgrades" :) 11:20
El_Che :)
11:25 soursBot joined
finanalyst lizmat: problem found. my whole os distribution was a year out of date. 11:27
lizmat good to hear the source of the issue was found :-) 11:28
finanalyst El Che: Thanks
Roamer`: why update apt first? Are there apt security issues? 11:30
Roamer` finanalyst, nah, but sometimes there are new features, some minor bugfixes, I like to make sure that apt will handle everything correctly during a large upgrade 11:31
as I said, a paranoid control freak :)
finanalyst I understand. 11:32
Roamer` (which doesn't stop me from doing daily upgrades from Debian testing on my laptop, sometimes bringing surprises like today's vlc/smplayer/mesa segfault)
finanalyst My upgrade was seemless today. I have to work out why the daily upgrades stopped. 11:34
11:37 sena_kun joined 11:39 Altai-man_ left 11:46 soursBot left 11:48 soursBot joined
El_Che Roamer`: I remember my pre Ubuntu days :) 11:50
11:52 mowcat joined, xinming left, xinming joined 11:59 aborazmeh joined, aborazmeh left, aborazmeh joined 12:00 Celelibi joined, mowotter joined 12:03 mowcat left 12:12 aborazmeh left 12:37 sno left 12:47 soursBot left 12:53 xinming left, xinming joined 12:56 rainmanjam left, rainmanjam joined 13:12 pilne joined 13:13 pilne left 13:17 soursBot joined 13:36 Altai-man_ joined 13:37 grondilu joined 13:38 sena_kun left
grondilu Hi. I want to enumerate the permutations of a list of lists. I've tried something like for (@this, @that, @those).permutations { my (@a, @b, @c) = @$_; } but it doesn't seem to work. What am I missing ? 13:39
jnthn That the @a will slurp up everything (it's a list assignment, not a destructure); true := instead 13:40
grondilu that seems to work, thanks :) 13:41
unrelated : is 'use v6;' still a thing after the renaming ? 13:49
13:55 finanalyst left, lichtkind joined 13:56 squashable6 left
Roamer` grondilu, "use v6" by itself still works, yes, and the more useful forms "use v6.d" or, for the very, very few programs that will break, "use v6.c", will also work and will also cause Perl 5 to break if you run it by mistake 13:58
(at least it's my impression that very few programs written for v6.d will break on v6.c; if I'm wrong, anybody, feel free to correct me)
um, the other way 'round, of course! very few programs written for v6.c will actually break on v6.d 13:59
13:59 squashable6 joined 14:05 mowotter left 14:09 oddp left 14:27 melezhik joined
melezhik I am thinking about writing a series of post on Azure Devops automation using Raku and Sparrow. I wonder if anyone is interested in the topic? 14:29
tellable6 2020-06-06T12:11:21Z #raku-dev <tbrowder> melezhik: good idea for your "spare" time but such testing is not a high need for me.
14:29 grondilu left 14:34 sarna left
melezhik .tell tbrowder - I see, NP. 14:34
tellable6 melezhik, I'll pass your message to tbrowder
14:41 soursBot left
rbt Is there a standardized deprecation policy for Raku? Timeline between marking the code as deprecated and removing it? 14:42
tbrowder finanalyst: i’ve been very pleased with the rakudo-pkg for debian 14:45
tellable6 tbrowder, I'll pass your message to finanalyst
jnthn rbt: Approximately, something should report itself as deprecated for at least one major language release before being removed. 14:46
ShimmerFairy So long as it's something in core.*/ , it should never need to be removed, unless you wanted to remove support for particular versions of the standard.
rbt It's actually for a module (DBIish). 14:48
14:49 soursBot joined
rbt It has a bunch of partly functional (and long replaced) code. Would 1 or 2 years be reasonable warning? 14:49
14:50 molaf left 14:52 skids joined 14:57 patrickb left 15:07 brtastic left 15:08 rbt left, rbt joined 15:20 RaycatWhoDat joined
RaycatWhoDat p6: say $_ ~ "ack" for 'J'..'Q' 15:20
camelia Jack
Kack
Lack
Mack
Nack
Oack
Pack
Qack
RaycatWhoDat facepalms
So, in "one-liner mode", this same code throws an error. Why is that? 15:22
It's the "unsupported use of bare say" error. 15:23
ShimmerFairy shell syntax is getting to you, I'm certain
15:24 patrickb joined
RaycatWhoDat Oh 15:24
You're absolutely right
15:24 melezhik left
ShimmerFairy I always use single quotes to surround an argument to -e precisely to avoid the issue :) 15:24
RaycatWhoDat Got it. I will keep that in mind next time. 15:25
Thanks for the help. 15:26
ShimmerFairy np 15:27
[Coke] perl5 question: anyone know what "BBC" is referring to here? github.com/Perl/perl5/issues/17567 is it bbc.co.uk? 15:36
15:37 sena_kun joined 15:39 Altai-man_ left
afresh1 I believe it is Blead Breaks CPAN 15:39
Grinnz correct 15:40
some (extremely helpful) users run CPAN smokers using blead, and notify the developers when their changes have started causing failures 15:41
15:46 Sgeo joined 15:55 abraxxa left 15:56 patrickb left
[Coke] very cool 16:08
thanks!
16:10 lichtkind left 16:12 oddp joined 16:13 JJMerelo joined 16:23 lichtkind joined 16:27 finanalyst joined 16:29 vike1 left 16:30 soursBot left 16:35 KindTwo joined 16:37 KindOne left 16:39 dakkar left 16:40 melezhik joined, KindTwo is now known as KindOne 16:41 soursBot joined
melezhik .tell Grinnz, Blead Breaks CPAN - this what is what done by Blin or RakuDist in Raku 16:42
tellable6 melezhik, I'll pass your message to Grinnz
melezhik at least at somewhat level
16:45 molaf joined 16:56 OpenZen joined 17:04 mowcat joined 17:08 softmoth joined 17:11 rbt left
softmoth \o 17:11
tellable6 2020-06-09T09:41:01Z #raku-dev <JJMerelo> softmoth not really. I really love what you're doing. There's another fork, which is mine, but it does not go any further than the original.
17:11 rbt joined
JJMerelo hi, softmoth. 17:11
Again, thanks and let's go ahead with that
softmoth Hi!
RaycatWhoDat What are the requirements for a method to be called with the invocant first? 17:12
So, if I make a sub like `sub test(Int $input) {!!!}`, what do I need to call it like: `12.test`? 17:13
17:13 lichtkind left
softmoth JJMerelo, Thanks! I'll move forward on it in softmoth/rakudoc for now. Do you agree w/ moving it to Raku/rakudoc? I'm not in github:Raku org, but I don't mind either submitting PRs or being added, whichever is best for you. Or leaving it on softmoth/rakudoc, too, although I do think it should be under Raku. 17:14
17:15 MasterDuke left
softmoth RaycatWhoDat, you can put it in a class or a role, as `method test(Int $input)` 17:18
17:18 kensanata left 17:20 rindolf left
RaycatWhoDat Ah, got it. 17:21
[Coke] If you want to modify an existing (core) class, there are a few extra steps.
You can, I think, force a sub to be called "like" a method, but there are extra steps there as well. (trying to find that part of the doc) 17:22
17:24 rindolf joined
[Coke] m: my $a = "a string"; my method test { return "this is {self}" }; say $a.&test; 17:25
camelia this is a string
[Coke] ^^
I'd file that under tmtowtdi, and put the method in a class, though. :)
17:27 vike1 joined
JJMerelo softmoth I think it would be a good idea. I could add you either to the team or to the specific repo 17:35
17:36 Altai-man_ joined 17:38 sena_kun left 17:40 melezhik left
jdv79 [Coke]: enron? really? weren't they in texas or something... 17:44
softmoth JJMerelo, it might make sense to add me to the team; I'm on perl6 but somehow missed the transition 17:52
JJMerelo Let me see if I can do that
softmoth done, you should have received the invitation 17:53
And welcome back
17:54 chloekek joined
[Coke] jdv79: yes, I lived in Houston for a bit 17:57
softmoth JJMerelo, I got it. Thanks again! 17:59
JJMerelo softmoth++ 18:00
18:01 devmikey left 18:05 soursBot left, hacktor left
jdv79 [Coke]: ah, cool 18:07
guifa [Coke]: when you call a sub in the method syntax ( my &sub = sub { … }; $foo.&sub ), all that happens is the the invocant is passed as the first argument
18:07 hacktor joined
guifa so $foo.&sub($bar) is the same as sub($foo, $bar) 18:07
It’s pretty DWIM assuming that — as is normally the case — a sub is written with its first positional argument being the “main” one 18:08
18:08 soursBot joined 18:09 Xliff left 18:12 hacktor left, hacktor joined 18:16 hacktor left 18:17 stoned75 left 18:19 stoned75 joined 18:24 sauvin left
softmoth JJMerelo, It's moved to github.com/Raku/rakudoc ; the only thing missing is it's not showing up (yet?) in travis-ci.org/github/Raku . I don't know if I need to do something more there. 18:32
18:36 lichtkind joined 19:02 rainmanjam left 19:07 soursBot left, soursBot joined 19:11 rbt left 19:12 rbt joined 19:21 MasterDuke joined
softmoth It's odd, the travis build badge is green now: api.travis-ci.org/Raku/rakudoc.svg...nch=master But when I go to travis-ci.org/Raku/rakudoc it says they couldn't display the repo. I've logged out & back in to Travis. I have to go now, but will look at it later. 19:21
19:23 rainmanjam joined, melezhik joined, molaf left 19:24 poohman joined
poohman hello all, 19:24
m: say "test"~~/\U+000C/ 19:25
camelia 5===SORRY!5=== Error while compiling <tmp>
Unrecognized backslash sequence: '\U'
at <tmp>:1
------> 3say "test"~~/\7⏏5U+000C/
expecting any of:
term
poohman In the documentation for regex, it is mentioned that form feed FF is \U+000C
cant I directly use it in a regex? 19:26
19:27 softmoth left
jnthn m: say "test"~~/\xC/ 19:28
camelia Nil
jnthn m: say "test"~~/\f/ # but I think this is available too...
camelia Nil
poohman thanks - was just reading a ticket more documentation for this 19:33
oddp .comb allows grouping/chunking of adjacent chars: 19:35
m: "abaabba".comb(/(.) $0*/)
camelia ( no output )
19:35 soursBot left
oddp m: say "abaabba".comb(/(.) $0*/) 19:36
camelia (a b aa bb a)
oddp Is there perhaps a more abstract routine in the stdlib that works also for non-string seqs with a custom equality predicate?
categorize, classify and .Bag don't preserve that property:
19:36 soursBot joined
oddp m: say <a b a a b b a>.categorize({$_}) 19:36
camelia {a => [a a a a], b => [b b b]}
19:37 sena_kun joined
jnthn oddp: Maybe .repeated 19:37
19:38 Black_Ribbon joined
jnthn Though I don't think that's quite what you want 19:38
19:38 Altai-man_ left
oddp Nope. 19:38
Looking for the equivalent of this ruby snippet: 19:39
%w(a b a a b b a).chunk(&:itself).to_a
=> [["a", ["a"]], ["b", ["b"]], ["a", ["a", "a"]], ["b", ["b", "b"]], ["a", ["a"]]]
If it's not in the stdlib then that's fine, just wanted to make sure I'm not overlooking something since each and every lang calls these routines differently. :) 19:41
19:41 soursBot left
[Coke] m: "abaabba".comb(/(.) $0*/).map({.substr(0,1), $_}) 19:41
camelia ( no output )
[Coke] m: dd "abaabba".comb(/(.) $0*/).map({.substr(0,1), $_}) 19:42
camelia (("a", "a"), ("b", "b"), ("a", "aa"), ("b", "bb"), ("a", "a")).Seq
[Coke] I haven't seen behavior like that before.
easy enough to throw that in a routine, though. 19:44
oddp Yeah, that works for chars and the like, but not for various objects with arbitrary eqv checks.
jnthn oddp: Yeah, I think can't think of a built-in that does exactly that
squish has the information in its hands but throws it away 19:45
[Coke] yah, the comb assumes a string: one sec.
jnthn Well, that's not quite true, it doesn't actually have to keep count of how many things it discarded
oddp "I haven't seen behavior like that before." - It's called group_by/group some other langs (e.g. rust, d, haskell). 19:50
Ruby is the outlier here when it comes to naming these things.
[Coke] does the result need to be an array? Most of things like classify/categorize are hash-generating. 19:51
also, I assume that if it should generalize to more than 2 in a row? 19:52
19:55 pilne joined 19:59 xelxebar left 20:00 xelxebar joined 20:02 JJMerelo left 20:04 chloekek left 20:06 aborazmeh joined, aborazmeh left, aborazmeh joined
[Coke] this seems like it would require a multiline sub. Hopefully someone can suggest a shorter way. :) 20:10
20:14 epony left 20:15 epony joined 20:16 rindolf left
oddp Sorry for the delay. 20:17
In this very case I'm only interested in the number of adjacent elements that match a certain predicate. Each language seems to represent the result in a slightly different manner.
haskell, for example, as a lazily accumulated list:
>>> groupBy (<=) [1,2,2,3,1,2,0,4,5,2]
en.wikipedia.org/wiki/Special:Searc...[0,4,5],[2
oops.
=> [ [1,2,2,3],[1,2],[0,4,5],[2] ]
dlang, on the other hand, as an value => count pair iterator. 20:18
[Coke] If you didn't care about repeated items, you could use one of the builtins. (that is, your sample could have two separate runs of as that need to be reported differently) 20:20
MasterDuke could you do something with reduce?
20:20 finanalyst left
oddp I went with plain old while loop and an accm array. :) 20:21
[Coke] oddp++
20:22 sno joined
wamba m: multi reducer ( @a,$i where * eqv @a.tail.key ) { |@a.head(*-1), @a.tail.key => [|@a.tail.value,$i] }; multi reducer (@a, $i) { |@a,$i=>$i }; say <a b a a b b a>; dd reduce &reducer, [],|<a b a a b b a> 20:24
camelia (a b a a b b a)
(:a("a"), :b("b"), :a(["a", "a"]), :b(["b", "b"]), :a("a"))
20:27 finanalyst joined 20:28 poohman left 20:29 sjm_uk left 20:40 wamba left
oddp .tell wamba, Thanks, appreciated, will see whether I can mold this a bit and add it to a small utils lib. 20:42
tellable6 oddp, I'll pass your message to wamba
oddp A quick question about this statement here: |@a, $i => $i. Will this iterate through the whole array before appending an element?
Or is the the slip essentially optimized away? 20:43
20:45 finanalyst left 20:47 vike1 left 20:50 wamba joined, stoned75 left 20:52 schlaftier left
Nasrudin So consider this class: class MyCmd { has Sub &.runme; }; 20:56
If I try this: my $x = MyCmd.new( runme => sub ($a,$b) { say "Hi" } );
it fails with Type check failed in assignment to &!runme; expected Callable[Sub] but got Sub
Can anyone explain this behavior? I'm very new to Raku so bear with me please. :D 20:57
20:59 vike1 joined
jnthn The sigils other than $ already imply a type, so the & already implies something Callable 20:59
In general, the type is "what do I get out of this", and you get something out of a callable by calling it. So `has &.runme` is enough to express "something I can call" 21:00
`has Sub &.runme` means it has to be something that has a declared return type of Sub 21:01
Nasrudin Ah! That's clear, thank you. :) 21:04
What if I want to specify a signature that the assigned "code reference" (honestly don't know what else to call it) must have? 21:05
I can't use '&' right?
I have to make my own type
and use '$'
21:12 lichtkind left 21:14 RaycatWhoDat left 21:20 vike1 left 21:26 vike1 joined 21:30 skids left 21:36 Altai-man_ joined, wamba left 21:38 sena_kun left 21:46 molaf joined 22:04 lichtkind joined 22:10 rbt left 22:11 rbt joined 22:18 dsgsdgsdg joined, dsgsdgsdg left 22:27 aborazmeh left 22:29 kst joined 22:42 girafe left 22:43 girafe joined 22:45 melezhik left 23:06 pecastro left 23:16 MasterDuke left 23:21 schlaftier joined 23:37 sena_kun joined 23:38 Altai-man_ left 23:40 marcusr left, marcusr joined 23:41 softmoth joined 23:44 lichtkind left 23:56 mowcat left