»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'p6: say 3;' or rakudo:, or /msg camelia p6: ... | irclog: irc.perl6.org or colabti.org/irclogger/irclogger_logs/perl6 | UTF-8 is our friend!
Set by moritz on 22 December 2015.
George hi 02:09
what is this? 02:10
teatime It's a dream, George. 02:11
(This is the user support / discussion channel for the Perl 6 programming language)
comborico1611 Heh 02:21
I once showed my school buddy back in 1999 IRC connecting, and he thought i was "hacking". 02:22
I had the background black, and all the flashing text and colors looked hacker legitimate. 02:23
George I mean what kind of information can one ask for here?
comborico1611 Information about the programming language Perl 6. 02:24
George It says how to get started, but 'm just reading the tutorial, I was just curius about it 02:25
I've never seen this sort of thing before 02:26
teatime You're welcome to ask questions etc. that come up as you go through it.
Like Perl6? Or an IRC help channel?
comborico1611 I was curious about programming back in 2000, then 17 years and by, and just this summer i got back into it.
I'm pretty sure he means irc. 02:27
George both acually 02:27
comborico1611 I think his head is reeling a bit by the ircness of irc.
Heh 02:28
George I come from Haskell
comborico1611 Weird. Know any others?
George they say perl 6 is functional so I was giving i a try
like programming languages?
yes 02:29
teatime it can be, I really like how successfully it is 'multi-paradigm'
George I mean I started learning haskell recently
comborico1611 Oh okay. Not weird anymore.
teatime I have tried to learn Haskell about 3 times.
I think I must have been smarter when I was younger.
George I am liking it actually
comborico1611 I got the impression you were a young'n that hadn't been introduced to the programming culture. 02:30
rashipi At one point, a Perl6 compiler was the most important Haskell aplication and drove Haskell development.
teatime yiss
although it was before my time with it
comborico1611 Hmm. Didn't know that.
rashipi As languages, they were developed togheter.
teatime but the links between haskell and perl6 become apparent from time to time 02:31
comborico1611 Hmm.
George yes I heard that
George but if one has never coded in perl before is perl6 a good starting point? 02:31
geekosaur I'd argue it's a better starting point than perl 5, unless you need to use perl 5 later. 02:32
perl6 is much less idiosyncratic --- it behaves consistently, whereas perl 5 is kinda infamously a mass of special cases
teatime perl6 is fun. that's about all I can contribute. 02:33
(perl5 was a lot of fun too, but I don't think it would be again if I were starting today.) 02:34
George yes I'm starting to get an idea from the pearl from Haskell tutorial and the one from Python
rashipi Pearl is another language. 02:36
teatime George: the name misleads a lot of people into thinking they're super-closely-related; they're not so much, they're different languages.
perl 6 and 5 I mean
George ok ok
geekosaur they're conceptually related, nbut that's as far as it goes 02:37
geekosaur there's a number of core ideas that are in common, intentionally, which is why we call it perl. but perl 6 is taking advantage of a lot of general development in programming languages to express those core ideas in a more consistent and better organized way 02:38
comborico1611 George, what languages do you know? 02:41
George C/C++ Python and \JS
and a little of PHP 02:42
comborico1611 I've never heard of the backslash one.
teatime "escape JavaScript" is a popular developer goal :)
George thats a typo
comborico1611 Lol 02:43
George ahahah
comborico1611 That's good stuff. I better get some sleep. Goodnight. Hope to see you on here George. 02:44
George Thanks comborico1611!
George Thanks to teatime, geekosaur and everyone else who has answered my questions but I think I have to go myself 02:46
teatime Take it easy, and welcome.
Herby_ with regex and grammers, what is the difference between | and || 03:14
if any
teatime there is a difference, 1 second
I beleive one matches in order given and the other matches longest alternative 03:15
but let me find the actual docs
docs.perl6.org/language/regexes#Alternation:_||
rashipi | is for longest match 03:16
|| is left to right.
Herby_ thanks!
rashipi 'dog || doge' will never match doge 03:18
Herby_ teatime: thanks for the link
Herby_ rashipi: and 'dog | doge' will always match doge? 03:22
assuming doge is actually in the string
teatime yiss
rashipi m: say 'doge is the word' ~~ /dog|doge/ 03:23
camelia 「doge」
rashipi m: say 'doge is the word' ~~ /dog||doge/ 03:24
camelia 「dog」
rashipi m: say 'doge is the word' ~~ /doge||dog/
camelia 「doge」
Herby_ grammars are hard 04:39
rashipi what you're trying to do? 04:48
Herby_ as an exercise, I'm trying to write a grammar to parse torrent names
pastebin.com/jwbjyQCv 04:52
the title matches everything except the end: -ASAP[ettv] 04:53
season, episode, and resolution dont match
rashipi because it's greedy 04:54
Put a ? to turn it frugal 04:55
that way it will match the least possible
Herby_ where do I put the ?
teatime heh I've never heard that called frugal... I like it 04:56
rashipi It's in the docs, haha
Then it will match a single letter
Herby_ no luck. 05:02
i'll look at it with fresh eyes tomorrow 05:03
o/
ZzZombo Say, I have a grammar rule A that calls rule B, can I in my actions object get the match for A for the corresponding match B inside the action method? 05:14
geekosaur uh? B doesn't know if it can only ever be called by A, and if tyhat *is* the case then there's likely some refactoring that will give you both 05:32
now if you mean from A's action method, B should be available as a named submatch 05:33
HoboWithAShotgun who is froggs? (github.com/FROGGS/p6-Archive-Tar) 07:30
wander m: my %h; my @a = [1,2,3]; %h<k> = %(name=>"kk", :@a); .say for %h<k><a>; .say for %h<k><a>.Array; 08:58
camelia [1 2 3]
1
2
3
wander Here is an interesting example, I think, of the topic "container" 08:59
"container" is considered as one of the most hard topic to understand of Perl 6 by people around me. 09:02
wander So I want to attempt to figure out how we design Perl 6 "container", the only article I found about it is from the doc site. 09:03
wonder if there someone ever talked about it, such like in a blog or something.
one of the most annoying cases is an Array `[ ... ]' sometimes becomes `$[ ...]` 09:05
mryan50 wander: [ … ] is an array container; $[ … ] is a scalar container holding a reference to an array container 09:35
… well, at leat I think that’s how it is 09:36
s/leat/least/ 09:37
wander yes, i know this. you can see the example above about '%h' and '@a', so @a happens to be convert form array to a refer, interesting and confusing when you first meet it. 09:39
wander scalar containers, callable containers and etc.. when they appear singly, things go well. but variable is passed and thus container changes, here things go, somehow, confusing 09:47
so i wonder if someone has had a talk about this topic :P 09:50
lizmat wander: do you have an example of something that confuses you? 09:55
wander no. i don't remember it, some i have met but fixed in someway so i forget it. i will ask for help if facing a very issue. however, my friends who i recommend Perl 6 to tell me the concept "container" is not so clearly 10:12
so i don't ask for help to fix a particular issue, but look for a talk about "container" 10:13
lizmat wander: jnthn.net/papers/2015-spw-perl6-course.pdf specifically the "Variables" chapter 10:19
wander thank you ^_^ 10:24
moritz wander: docs.perl6.org/language/containers 10:32
wander yes, i mention it above and be reading it :P 10:34
moritz sorry, didn't fully backlog 10:38
teatime morning moritz 10:39
and was gonna say lizmat
ZzZombo m: class A{ has %.b is default(Nil)};my $c:=A.new.b<asd>; my $a is default(Int)=A.new.b<asd>; say $a.VAR.perl 12:16
camelia Invocant of method 'perlseen' must be an object instance of type 'Mu', not a type object of type 'Int'. Did you forget a '.new'?
in block <unit> at <tmp> line 1
poohman hello all - I say the method "into" being used in one of Jonathans old presentations. but when I use it, it says undeclared routine. 14:29
I saw , I meant
masak on what type? 14:33
poohman I didnt mention any type - getting some content using a POST request - grepping it - and using into to shove it into a variable 14:35
my $content = await $resp.body; 14:36
$content
==> grep(/\V*'HREF'\V*\v+/)
==> into my $href;
something like this
HoboWithAShotgun ==> is a kind of into operator 14:36
ZzZombo remove `into`, be happy
poohman oh ok 14:37
poohman wow cool 14:37
thanks 14:38
need to work on my regex - but it compiled - thanks 14:39
masak HoboWithAShotgun++ 14:46
HoboWithAShotgun what's the praise for, masak? 14:50
masak helping poohman
HoboWithAShotgun how do itell github to merge a fricking pull request?
masak oh, and ZzZombo++ also :)
HoboWithAShotgun: usually there's a button
or you can do it locally 14:51
HoboWithAShotgun for which i am loking for for quite a while now ^^
oh, there. nvm 14:52
timotimo so scimon's slides have examples that make me think junctions misbehave with chained operators:
timotimo m: say 4 < 1^2^3^4^5 < 2; say say 4 < 1^2^3^4^5; say 1^2^3^4^5 < 2 14:53
camelia one(True, False, False, False, False)
one(False, False, False, False, True)
True
one(True, False, False, False, False)
ZzZombo <ZzZombo> m: class A{ has %.b is default(Nil)};my $c:=A.new.b<asd>; my $a is default(Int)=A.new.b<asd>; say $a.VAR.perl 15:56
err 15:57
m: class A{ has %.b is default(Nil)};my $c:=A.new.b<asd>; my $a is default(Int)=A.new.b<asd>; say $a.VAR.perl
camelia Invocant of method 'perlseen' must be an object instance of type 'Mu', not a type object of type 'Int'. Did you forget a '.new'?
in block <unit> at <tmp> line 1
ZzZombo ^
Herby_ o/ 16:02
APic \o
ZzZombo Hey, is it normal for older Rakudo installations in Windows to remain in the list of installed applications? 16:03
on*
Herby_ It doesn't for me but I always make a point to uninstall the previous installation first before installing the new 16:04
ZzZombo I just install over, since the installer doesn't complain, and also wouldn't it force me to reinstall all modules every time? 16:05
lizmat m: say Int.VAR.perl 16:06
camelia Int
lizmat hmmm
m: say (my Int $).VAR.perl # ZzZombo: golfed 16:07
camelia Invocant of method 'perlseen' must be an object instance of type 'Mu', not a type object of type 'Int'. Did you forget a '.new'?
in block <unit> at <tmp> line 1
Herby_ ZzZombo: possibly. I'm new to this :) 16:10
ZzZombo I wasn't even trying 😢 lizmat! 16:12
ZzZombo it just appeared in this piece of code and it scared me, so I needed somebody to tell me this will go away from me 16:13
lizmat seems something gets confused 16:14
but it also feels a bit like DIHWIDT
(aka Doctor, It Hurts When I Do This)
so don't do that :-)
using .VAR is generally a code smell 16:15
so why where you using that?
ZzZombo I'm not, the `.VAR.perl` part was only because I wanted be EXTRA sure I've got the right thing out of the hash, that is, Nil. 16:16
to be*
Geth doc: 7acf5e5f1f | (Elizabeth Mattijsen)++ | doc/Type/Telemetry/Period.pod6
Remove incorrect documentation from T:Period

  - this pod was from before the Instrument refactoring
  - a Telemetry::Period object is the same as a Telemetry object, only
   the *meaning* of the values is different.
16:22
synopsebot Link: doc.perl6.org/type/Telemetry/Period
lizmat m: class A{ has %.b is default(Nil)}; dd A.new.b<asd> # ZzZombo: quicker way to find out it gives Nil 16:24
camelia Nil %!b = Nil
ZzZombo yeah, but when assigning it to a variable, it turns into Any w/o asking, that all the fudge is about. 16:25
lizmat ZzZombo: "my $a" is short for "my Any $a", so assigning Nil to that *will* give you an Any 16:27
that's supposed to be the way it works
Geth doc: 2769ad2534 | (Elizabeth Mattijsen)++ | 2 files
Move snapper doc, it is not a Type
16:30
ZzZombo I see. The original issues wasn't even about that directly, it's about how could I pass a type in a hash to some function and use it or some default value if not present.
In a similar vein to `my $class=%h<class> // $default;$class.new` 16:31
Geth doc: 3354ac7e4f | (Elizabeth Mattijsen)++ | doc/Type/Telemetry/snapper.pod6
Make sure we link correctly to Telemetry
16:37
synopsebot Link: doc.perl6.org/type/Telemetry/snapper
doc: 0ed5cba7b1 | (Elizabeth Mattijsen)++ | doc/Type/Telemetry/Period.pod6
Make sure we link correctly to Telemetry
synopsebot Link: doc.perl6.org/type/Telemetry/Period
lizmat goes back to driving& 16:38
travis-ci Doc build errored. Elizabeth Mattijsen 'Move snapper doc, it is not a Type' 16:54
travis-ci.org/perl6/doc/builds/307527921 github.com/perl6/doc/compare/7acf5...69ad253493
buggable [travis build above] ☠ Did not recognize some failures. Check results manually. 16:54
travis-ci Doc build errored. Elizabeth Mattijsen 'Remove incorrect documentation from T:Period 16:56
travis-ci.org/perl6/doc/builds/307525868 github.com/perl6/doc/compare/fc30d...cf5e5f1fce
buggable [travis build above] ☠ Did not recognize some failures. Check results manually. 16:56
poohman m:say("Hello") 17:05
evalable6 Hello
poohman m:my $source = "abcd\n123\nyjk\n897\nn1n2n3k\n";my @lines = $source.lines;@lines ==> grep(/\d+/) ==> my @num
evalable6
poohman m: my $source = "abcd\n123\nyjk\n897\nn1n2n3k\n";my @lines = $source.lines;@lines ==> grep(/\d+/) ==> my @num 17:06
camelia ( no output )
travis-ci Doc build errored. Elizabeth Mattijsen 'Make sure we link correctly to Telemetry' 17:07
travis-ci.org/perl6/doc/builds/307530100 github.com/perl6/doc/compare/2769a...d5cba7b11a
buggable [travis build above] ☠ Did not recognize some failures. Check results manually. 17:07
poohman m: my $source = "abcd\n123\nyjk\n897\nn1n2n3k\n";my @lines = $source.lines;@lines ==> grep(/\d+/) ==> my @num; say @num;
camelia [123 897 n1n2n3k]
Geth doc: 8d7aaa52d3 | (Jan-Olof Hendig)++ | doc/Type/Complex.pod6
Added documentation for sqrt
17:08
synopsebot Link: doc.perl6.org/type/Complex
Grrrr 17:09
Herby_ anyone know how to get hexchat to properly display camelia's unicode characters? 17:10
teatime Herby_: Can you see → my arrows ↔ 17:12
Herby_ yep
teatime then I think your problem is just that your configured font lacks the glyphs being used
maybe try DejaVu instead 17:13
or Unifont, if you want an ugly font that has almost literally everything
(if you can specify a "fontstack" to search for glyphs, ending it with Unifont works great.)
Herby_ teatime: i'll give that a shot, thanks! 17:14
poohman m: my $source = "abcd\n123\nyjk\n897\nn1n2n3k\n";$source ==>lines ==> grep(/\d+/) ==> my @num; say @num;
camelia 5===SORRY!5=== Error while compiling <tmp>
Preceding context expects a term, but found infix ==> instead
at <tmp>:1
------> 3jk\n897\nn1n2n3k\n";$source ==>lines ==>7⏏5 grep(/\d+/) ==> my @num; say @num;
teatime works if you do lines() instead of lines 17:17
poohman m: my $source = "abcd\n123\nyjk\n897\nn1n2n3k\n";$source ==>lines() ==> grep(/\d+/) ==> my @num; say @num;
camelia [123 897 n1n2n3k]
poohman perfecto - thanks a lot
teatime well kindof
oh, yes, nevermind
poohman kindof??
teatime didn't realize the grep wasn't anchored 17:18
poohman is there a difference
teatime it works
teatime Herby_: looks relevant: hexchat.readthedocs.io/en/latest/ti...ial-glyphs 17:19
Herby_ m: say "Hello world"; 17:20
camelia Hello world
teatime looks like you can indeed specify a "font stack"
Herby_ teatime: I think I got it installed
went with unifont
thanks for the help!
teatime any time
travis-ci Doc build passed. Jan-Olof Hendig 'Added documentation for sqrt' 17:53
travis-ci.org/perl6/doc/builds/307539704 github.com/perl6/doc/compare/0ed5c...7aaa52d3ab
Geth doc: 023ac493d1 | (Jan-Olof Hendig)++ | doc/Type/Dateish.pod6
Fix formatting and a partly broken link
17:56
synopsebot Link: doc.perl6.org/type/Dateish
poohman m: my token {[01 ... 31]} 17:57
camelia ( no output )
geospeck are Roles similar to interfaces from other languages eg Java?
poohman m: my token day {[01 ... 31]} 17:58
camelia ( no output )
poohman could I use something like this in Grammar - stringify it in some way 17:59
??
teatime you can use it in a grammar without stringifying
poohman really - will it work directly?? 18:00
teatime yup
that's what it's for :)
poohman wow 18:01
let me try it
back to programming after some years - so I dont really know how it is with other languages - but is something like this possible in the new generation languages 18:03
i mean is this possible in most of the new generation languages
or is it perl6 magic here??
teatime grammars like Perl6 has are pretty unique to perl6 18:04
when feeling optimistic, I expect them to spread and be loved the same way perl5 advanced regular expressions 18:05
poohman 😆 - I tried the following just as a test - didnt want to be surprised again 18:06
m: my $months=['Jan', 'Feb' ...'Dec']
camelia ( no output )
teatime there are grammar/parser implementations for other languages (e.g. Marpa), and there is the older tech of parser generators etc., but perl6 builds it into the language, and makes it very quick and easy to get started with
heh, I don't expect that'll work 18:07
poohman It did give a result though
teatime m: say ['Jan', 'Feb' ... 'Dec'].first(12)
camelia Nil
teatime m: say ['Jan', 'Feb' ... 'Dec']
camelia [Jan Feb Fea Fdz Fdy Fdx Fdw Fdv Fdu Fdt Fds Fdr Fdq Fdp Fdo Fdn Fdm Fdl Fdk Fdj Fdi Fdh Fdg Fdf Fde Fdd Fdc Fdb Fda Fcz Fcy Fcx Fcw Fcv Fcu Fct Fcs Fcr Fcq Fcp Fco Fcn Fcm Fcl Fck Fcj Fci Fch Fcg Fcf Fce Fcd Fcc Fcb Fca Fbz Fby Fbx Fbw Fbv Fbu Fbt Fb…
teatime yup
poohman super cool 18:08
no I meant integration of lazy lists etc in Grammars
teatime oh
lists work like alternation, but I wouldn't think they stay lazy
poohman thanks teatime - time to hit the sack - seeya 18:12
teatime o/
travis-ci Doc build errored. Jan-Olof Hendig 'Fix formatting and a partly broken link' 18:19
travis-ci.org/perl6/doc/builds/307553269 github.com/perl6/doc/compare/8d7aa...3ac493d1a6
buggable [travis build above] ✓ All failures are due to: missing build log (1 failure). 18:19
lucs Where are string escape sequences documented? (like \n, \o, \c, etc.) 19:46
teatime lucs: there's more of it here than initially meets the eye, if you read the paragraphs: docs.perl6.org/language/quoting#Escaping:_q 19:50
if I'm not overlooking an exhaustive list elsewhere, though, it could def. be improved. 19:51
lucs Yeah, maybe it would be nice to have a list somewhere, cross-referencing to the proper documentation. 19:52
I'm actually wondering if there's an escape to enter a decimal value, like one enters an octal value (so \077 would be something like \d119). 19:54
teatime looks like \c[] should do it 19:56
\c[119]
ilmari m: say "\c[65]"
camelia A
teatime docs.perl6.org/language/unicode#En..._Sequences
lucs Looks good, thanks.
tyil I just noticed, there's no unicode op for -> and => in perl 6, is there? 19:57
for pointy blocks and fat commas
ilmari m: for 42 → $a { say $a } 19:58
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> 3for 427⏏5 → $a { say $a }
expecting any of:
block or pointy block
infix
infix stopper
ilmari m: for 42 -> $a { say $a }
camelia 42
gfldex m: say a ⇒ 42; 19:59
camelia 5===SORRY!5=== Error while compiling <tmp>
Bogus term
at <tmp>:1
------> 3say a 7⏏5⇒ 42;
expecting any of:
argument list
infix
infix stopper
postfix
prefix
statement e…
ilmari m: sub infix:<⇒>($a, $b) { $a => $b }; say foo ⇒ 42 20:00
camelia 5===SORRY!5=== Error while compiling <tmp>
Preceding context expects a term, but found infix ⇒ instead
at <tmp>:1
------> 3nfix:<⇒>($a, $b) { $a => $b }; say foo ⇒7⏏5 42
ilmari m: sub infix:<⇒>($a, $b) { $a => $b }; say 'foo' ⇒ 42
camelia foo => 42
gfldex m: constant term:<⇒> := &infix:«=>»; say 'a' ⇒ 42; 20:01
camelia 5===SORRY!5=== Error while compiling <tmp>
Confused
at <tmp>:1
------> 3onstant term:<⇒> := &infix:«=>»; say 'a'7⏏5 ⇒ 42;
expecting any of:
infix
infix stopper
postfix
statement end…
moritz m: constant term:<⇒> := &infix:«=>»; say ⇒ 20:39
camelia sub infix:«=>» (Mu $key, Mu \value) { #`(Sub+{is-pure}+{Precedence}|49597216) ... }
tyil docs.perl6.org/routine/unlink says unlink returns True if you give it a single path, but in practice it seems to return a list 21:18
cry.nu/p/7ijn
returns Array @ok = ["/tmp/0R14ZKUJ_U"]
are the docs out of date here (if so, I'll make a pr), or is this a bug? 21:19
Geth doc: 0a93d3f44d | (Elizabeth Mattijsen)++ | 2 files
Move snapper pod into Telemetry
21:20
lizmat tyil: good question, please make an issue out of it so we can discuss 21:24
theperlfisher.blogspot.nl/2017/11/t...hings.html # new blogging by DrForr
tyil I'm just rereading it, and it seems correct, the method would return True, but I use it as a sub(), which is slurpy and returns a list
"/tmp/filename".IO.unlink returns True as expected 21:25
I was already in the making of a ticket when I realized I was reading it wrong 21:26
travis-ci Doc build failed. Elizabeth Mattijsen 'Move snapper pod into Telemetry' 21:51
travis-ci.org/perl6/doc/builds/307614490 github.com/perl6/doc/compare/023ac...93d3f44d85
buggable [travis build above] ☠ Did not recognize some failures. Check results manually. 21:51
lizmat *sigh*
lizmat hmmm... the errors all seem to be in stuff I didn't touch ? 22:00
Geth doc: 8e8acb4556 | (Elizabeth Mattijsen)++ | doc/Type/Telemetry.pod6
Oops, =head 2 should be =head2
22:01
synopsebot Link: doc.perl6.org/type/Telemetry
wander morning ~ 22:14
lizmat: I close #1684 for your commit. Thanks for your effort :-) 22:15
lizmat wander: yw 22:16
gfldex I'm stuck with an error message, that goes: 22:35
X::Multi::NoMatch+{X::Await::Died}: Cannot resolve caller report(List, :html); none of these signatures match:
(*%_ --> Str:D)
(@s, :@columns is copy, :$header-repeat is copy, :$legend is copy, :$csv is copy, :@format --> Str:D)
(List, :$html is copy)
I'm pretty sure the last candidate could match
Juerd It does look rather matching :) 22:37
gfldex the first two candidates are in module A and the last one in module B 22:38
could that confuse Rakudo?
timotimo it shouldn't 22:39
you could try to output the candidates at the exact point it breaks
to make sure the list isn't different because of error reporting issues? 22:40
gfldex there is some nqp trickery in module A involved
in this line github.com/rakudo/rakudo/blob/mast...y.pm6#L714 22:41
(to me that nqp spell could very well open a gate to hell :) 22:42
no sorry, wrong line, right line: github.com/rakudo/rakudo/blob/mast...y.pm6#L721
timotimo ah, no 22:44
that's just a shorthand for "assign a value to this attribute and return the object that was assigned into" 22:45
i.e. do { bindattr($obj, Type, '$!attr', $value); $obj }
lizmat gfldex: do you have a gist of what you're trying to do? 22:59
gfldex lizmat: gist.github.com/e61d9f6153bffd7438...0c70d061ec 23:00
lizmat gfldex: why the is copy? 23:08
also, have you tried: (@s, :$html!) ? 23:09
Herby_ m: my @patterns = ('s', '\d\d'; 'e', '\w\w';); for @patterns -> $key, $value { say $key; say $value;}; 23:10
camelia (s \d\d)
(e \w\w)
Herby_ I'm messing something up. how do I loop through a multidem list? 23:11
lizmat @patterns.kv -> $key, $alue 23:14
Herby_ m: my @patterns = ('s', '\d\d'; 'e', '\w\w';); for @patterns.kv -> $key, $value { say $key; say $value;};
camelia 0
(s \d\d)
1
(e \w\w)
lizmat
.oO( looks like my v key bounces )
Herby_: then I'm not getting what you want (but then again I'm pretty tired) 23:15
Herby_ i'm not great at explaining myself :)
in the first loop, i'd like $key = 's', $value ='\d\d' 23:16
jnthn Try for @patterns -> [$key, $vlaue] { }
To unpack the sublist
gfldex lizmat: then I get: 23:17
X::Multi::NoMatch+{X::Await::Died}: Cannot resolve caller report(List, :html); none of these signatures match:
Herby_ m: my @patterns = ('s', '\d\d'; 'e', '\w\w';); for @patterns -> [$key, $value] { say $key; say $value;};
camelia s
\d\d
e
\w\w
gfldex (*%_ --> Str:D)
(@s, :@columns is copy, :$header-repeat is copy, :$legend is copy, :$csv is copy, :@format --> Str:D)
(@s, :$html is copy)
Herby_ jnthn: that was it, thanks
lizmat gfldex: and with just (:$html!) ? 23:21
gfldex lizmat: same
lizmat gfldex: you are calling report with only named parameters, right ? 23:23
gfldex lizmat: yes 23:24
jnthn multi sub report(List, :$html is copy) { will require a List to be passed, but I only see calls passing named arguments to it, and none passing an initial list positional 23:26
Am I missing something? 23:27
(Probably, 'cus I only glanced the discussion... :))
gfldex jnthn: I tried a proper @s too, both in the sig and the caller
lizmat gfldex: the @s is wrong: you don't need that
gfldex I know, I tried without too, to no avail 23:28
I shall golf and issue tomorrow. 23:29
Herby_ m: my $p = '(\d\d)'; say '23' ~~ / $p / 23:31
camelia Nil
Herby_ m: my $p = '(\d\d)'; say '23' ~~ / $($p) /;
camelia Nil
jnthn <$p> 23:32
Herby_ m: my $p = '(\d\d)'; say '23' ~~ / <$p> /;
camelia 「23」
Herby_ :)
thanks
Herby_ m: my $p = '(\d)\d'; if '23' ~~ / <$p> / { say $0; } 23:42
camelia Nil
Herby_ where am I going wrong? (sorry to pepper with questions)
jnthn Expecting regexes to be stringier than they are. In fact, they're more like subs, and the match state is per sub 23:44
m: my $p = '(\d)\d'; if '23' ~~ / <p=$p> / { say $<p>[0]; } 23:45
camelia 「2」
Herby_ my ultimate goal is I have an array of pattens, and I want to loop through the array and apply the patterns to a string and extract the captures
jnthn Can explicitly capture it like that
m: my $p = '(\d)\d'; if '23' ~~ / <p=$p> / -> :p($/) { say $0; } # hmm :) 23:46
camelia Cannot resolve caller postcircumfix:<[ ]>(Mu, Int); none of these signatures match:
(\SELF, Any:U $type, |c is raw)
(\SELF, int $pos)
(\SELF, int $pos, Mu \assignee)
(\SELF, int $pos, Mu :$BIND! is raw)
(\SELF, int $pos, …
jnthn m: my $p = '(\d)\d'; if '23' ~~ / <p=$p> / -> (:p($/)) { say $0; } # hmm :) 23:47
camelia 「2」
jnthn That lets you refer to the inner things as $0 etc.
Herby_ jnthn: thanks. i'll have to try and parse that mentally :) 23:48
perlawhirl Herby_: alternatively... eval your string into an Regex... unless it makes you feel dirty
ie: my $s = '(\d)\d'; my $p = EVAL("/$s/"); if '23' ~~ $p { say $0; } # Can camelia EVAL?
m: use MONKEY-SEE-NO-EVAL; my $s = '(\d)\d'; my $p = EVAL("/$s/"); if '23' ~~ $p { say $0; } 23:49
camelia 「2」
jnthn If you're going to apply them many times, that would probably be more performant, yes 23:50
Well, if doing all the EVALs up front I mean
Herby_ perlawhirl: thanks. I don't feel dirty cause I still am trying to figure out what I'm doing :)
perlawhirl yeah... @patterns = @strings.map: -> $s { EVAL("/$s/") } # now you have a list of Regex's 23:51
Herby_ perlawhirl and jnthn: thanks for the ideas 23:53
perlawhirl lizmat: I tried out toggle. I like it so far... provides something akin to takewhile/dropwhile, but more general. 23:57