»ö« 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.
bioduds_ hi ugexe 00:36
how are you doing?
tushar I am trying to implement multi methods. "multi method get-row (Int :$index! --> Array) { code.. }" and "multi method get-row (Array :@index! --> Array) { code.. }". When I try to call one of them "$obj.get-row(index => [0..2]);", I am experiencing an error stating "Cannot resolve caller AUTOGEN(DataTable: Array); none of these signatures match:". Any idea why any of them are not found? Is there anything wrong that I am doing? 02:23
yoleaux 23 Sep 2016 02:05Z <BenGoldberg> tushar: For a conventient way to install libmagic, consider using the perl5 module Alien::LibMagic.
tushar BenGoldberg: Thanks 02:24
geekosaur wonders if multis can dispatch solely on named parameters currently 02:29
tushar geekosaur: can elaborate your statement? Thanks. 02:30
you*
geekosaur all the examples I've seen of multis have at least one positional parameter they can dispatch on type. your multis have each one named parameter and no positiona;s 02:31
ugexe m: class Foo { multi method get-row (Int :$index! --> Array) { ["int",] }; multi method get-row (:@index! --> Array) { ["array",] } }; say Foo.new.get-row(index => 1); say Foo.new.get-row(index => [1..2])
camelia rakudo-moar 690d4a: OUTPUT«[int]␤[array]␤»
geekosaur ok, guess that works 02:32
can you provide a bit more context for the program and the error, tushar?
raydiak m: multi get-row (Int :$index! --> Array) { say 0 }; multi get-row (Array :@index! --> Array) { say 1 }; get-row(index => [0..2]);
camelia rakudo-moar 690d4a: OUTPUT«Cannot resolve caller get-row(Array); none of these signatures match:␤ (Int :$index! --> Array)␤ (Array :@index! --> Array)␤ in block <unit> at <tmp> line 1␤␤»
ugexe im assuming they are having problems doing `Array :@already-an-array`
otherwise 02:33
m: class Foo { multi method get-row (Int :$index! --> Array) { ["int",] }; multi method get-row (Array :$index! --> Array) { ["array",] } }; say Foo.new.get-row(index => 1); say Foo.new.get-row(index => [1..2])
camelia rakudo-moar 690d4a: OUTPUT«[int]␤[array]␤»
raydiak m: multi get-row (Int :$index! --> Array) { [] }; multi get-row (Array :@index! --> Array) { [] }; get-row(index => [0..2]); 02:34
camelia rakudo-moar 690d4a: OUTPUT«Cannot resolve caller get-row(Array); none of these signatures match:␤ (Int :$index! --> Array)␤ (Array :@index! --> Array)␤ in block <unit> at <tmp> line 1␤␤»
ugexe m: my Array @index; say @index.perl; # [0..2] does not pass this constraint 02:36
camelia rakudo-moar 690d4a: OUTPUT«Array[Array].new()␤»
raydiak ah ha
tushar geekosaur: Sure, I am implementing a method in which user can supply a single value or an array with values. I hope this clarify things.
raydiak m: multi get-row (Int :$index! --> Array) { [] }; multi get-row (Array :$index! --> Array) { [] }; get-row(index => [0..2]); 02:37
camelia ( no output )
geekosaur mm, I meant actual code and the code context for the error message
since the error you got is ... somewhat odd
I could see it being internal but I don't recognize AUTOGEN(DataTable: Array) 02:38
tushar ugexe: you are damm right about it. I always forget that when you use sigil "@", it says I am an array and you don't need to set "Array" type. When you specify "Array" type with "@" it expects to have array of array of array.
geekosaur AUTOGEN's a thing but DataTable isn't 02:39
tushar geekosaur: I will provide paste bin for that in a minute.
DataTable is my module name.
raydiak also, the way the error seems to suggest that an array was passed positionally is LTA 02:40
geekosaur ah. this sounds like an internals leak reported LTA
yeh
(I suspect AUTOGEN should never show up in an error message from a user error) 02:41
BenGoldberg m: multi m(Int $:i) { say 1 }; multi m(Array $:i) { say 2 }; m( i:(1) } 02:44
camelia rakudo-moar 690d4a: OUTPUT«5===SORRY!5===␤In signature parameter, placeholder variables like $:i are illegal␤you probably meant a named parameter: ':$i'␤at <tmp>:1␤------> 3multi m(Int $:i7⏏5) { say 1 }; multi m(Array $:i) { say 2 ␤In signature parameter, placeho…»
BenGoldberg m: multi m(Int :$i) { say 1 }; multi m(Array :$i) { say 2 }; m( i:(1) }
camelia rakudo-moar 690d4a: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤You can't adverb i␤at <tmp>:1␤------> 3; multi m(Array :$i) { say 2 }; m( i:(1)7⏏5 }␤»
BenGoldberg m: multi m(Int :$ix) { say 1 }; multi m(Array :$ix) { say 2 }; m( ix:(1) } 02:45
camelia rakudo-moar 690d4a: OUTPUT«===SORRY!===␤This type (QAST::WVal) does not support positional operations␤»
tushar geekosaur: here is the pastebin : pastebin.com/KBhfcz45
BenGoldberg Well, that's definitely a LTA error message :)
tushar what is LTA? 02:46
BenGoldberg Less than Awesome
Perl6 is supposed to have super awesome error messages, and never something nonsensical. 02:47
geekosaur basically means a crap error message, or one that leaks internals
tushar seriously?.. haha..
that's why I love perl 6..
geekosaur ideally the error messages are clear and helpful
sometimes this isn't possible just because it's impossible to tell what was intended, though >.>
BenGoldberg Anything mentioning QAST is LTA, since that's internal to rakudo. 02:48
geekosaur strong AI is not (yet?) a feature of perl6
yep. as is AUTOGEN, which is what makes the error you got kinda terrible
tushar I am looking forward to strong AI..
BenGoldberg "And you can't adverb i" only makes sence if you happen to know that perl6 has support for complex, and 'i' is reserved for making imaginary numbers. 02:49
s/sence/sense/
BenGoldberg 's fingers are stilly tpying nsense tday. 02:51
geekosaur aaand pastebin is giving me "Please refresh the page to continue" again. ad-ridden POS. 02:54
tushar geekosaur: that's wierd. Because when I clicked on it, it works fine.. 02:57
geekosaur I think it just gets grouchy when people load the raw URL to avoid the ads 02:59
sometimes it works, sometimes you get that and it refuses to ever load (refreshing doesn't get the paste, neither does shift-refresh) 03:00
tushar try this Github Gist -- gist.github.com/tushardave26/5e9d7...08de5b497d . Hope this works.
AlexDaniel acmmittolbe6: HEAD say 42 # :D 03:12
committable6 AlexDaniel, ¦«HEAD»: 42
AlexDaniel levenstein kinda makes sense. Sift4 is fast but wtf? How?? :D 03:14
TEttinger AlexDaniel: woah 03:22
table6commit: HEAD say "wow" 03:23
tablecommit6: HEAD say "wow"
AlexDaniel TEttinger: you can use this to test it: siderite.blogspot.com/2014/11/supe...tance.html 03:24
TEttinger: it currently triggers on anything that is ≤3
bisectable and benchable are set to trigger on distance ≤2 because guess what, the distance between bisectable6 and benchable6 is 3. :D 03:25
bectable6: exit 0 # /o\ 03:27
benchable6 AlexDaniel, starting to benchmark the 1 given commits
AlexDaniel, ¦«exit»:Cannot find this revision
bisectable6 AlexDaniel, On both starting points (old=2015.12 new=376b5f4) the exit code is 0 and the output is identical as well
AlexDaniel, Output on both points:
TEttinger heh 03:28
geekosaur heh
raydiak m: Nil.?Str 04:38
camelia rakudo-moar 9dcde7: OUTPUT«Use of Nil in string context␤ in block <unit> at <tmp> line 1␤»
raydiak should that warning be silenced?
geekosaur didn't it do what you asked it to? 04:42
m: dd Nil.?Str
camelia rakudo-moar 9dcde7: OUTPUT«Use of Nil in string context␤ in block <unit> at <tmp> line 1␤""␤»
geekosaur hm, guess not
thought it was producing Nil from the .?
so yes that seems LTA 04:43
m: dd Nil
camelia rakudo-moar 9dcde7: OUTPUT«Nil␤»
geekosaur ...right, that'd be wrong then.
m: dd Nil.Str 04:44
camelia rakudo-moar 9dcde7: OUTPUT«Use of Nil in string context␤ in block <unit> at <tmp> line 1␤""␤»
geekosaur ah. so Nil actually has a Str method which throws that 04:45
making .? kinda useless in that context
raydiak yeah dunno how we'll fix that :) but I'll at least file a bug report some time tonight 04:46
TimToady yeah, .? is about finding the method, not about checking the result 04:47
geekosaur right, the assumption was that there was no such method so $var-that-might-be-Nil.?Str could do something saneish
(I think)
TimToady well, a $var generally can't be Nil unless you bind it 04:48
raydiak named capture inside an optional branch of the regex
TimToady well, that's bound :) 04:49
raydiak I have "$<title> ?? $<title>.Str !! Nil" scattered around in my actions. it doesn't feel very nice. how would you write it?
geekosaur m: say Nil // '' 04:50
camelia rakudo-moar 9dcde7: OUTPUT«␤»
geekosaur m: say (Nil // '').Str
camelia rakudo-moar 9dcde7: OUTPUT«␤»
TimToady with $<title> { .Str } 04:51
m: my $x := Nil; say ($x andthen '')
camelia rakudo-moar 9dcde7: OUTPUT«()␤»
TimToady m: my $x := Nil; say ($x andthen $x) 04:52
camelia rakudo-moar 9dcde7: OUTPUT«()␤»
TimToady m: my $x := 42; say ($x andthen $x)
camelia rakudo-moar 9dcde7: OUTPUT«42␤»
TimToady m: my $x := 42; say ($x with $x)
camelia rakudo-moar 9dcde7: OUTPUT«42␤»
TimToady m: my $x := Nil; say ($x with $x)
camelia rakudo-moar 9dcde7: OUTPUT«()␤»
raydiak I suppose it doesn't matter if the undefined thing it returns is Nil or (). Thank you for the help that is quite a bit nicer 04:53
FROGGS o/ 08:24
timotimo o/ 08:28
psch o/
ab6tract s: Duration, "new" 08:56
SourceBaby ab6tract, Sauce is at github.com/rakudo/rakudo/blob/9dcd...tion.pm#L5
ab6tract was expecting Duration to support the named arguments like :8hours . obviously we might not want to support months or even weeks, but surely minutes and hours would be useful here? 08:59
psch sounds reasonable to me 09:00
FROGGS enjoys perl6.fail 09:35
st_iron good morning my friends 10:04
tailgate morns 10:28
RabidGravy I don't suppose anyone has a clone of HTTP::Server::Tiny handy? I'm struggling to work out the reason for the deadlock in t/12-supply.t 11:40
the actual thing it's testing (i.e. returning a Supply as the body of the response,) works if the client and server are in separate processes 11:45
just not in the test
and it definitely did work fine at some point 11:46
samcv what am i doing wrong with this regex? $line ~~ s/^%// 11:53
psch samcv: what's it supposed to mean? what's the failure mode? 11:54
samcv it's supposed to remove a % at the start of a line
psch m: /^%/
camelia rakudo-moar 448f82: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Missing quantifier on the left argument of %␤at <tmp>:1␤------> 3/^%7⏏5/␤»
samcv yep 11:55
i'm not sure what i did wrong
psch samcv: docs.perl6.org/language/regexes#Mo...ntifier:_%
m: say "1, 2" ~~ / \d+ % ', '/
camelia rakudo-moar 448f82: OUTPUT«「1, 2」␤»
samcv ok so i need to escape it?
psch samcv: yes, you need to escape everything that's not alnum 11:56
samcv: or quote it
samcv so $line ~~ s/^'%'// would work?
psch m: say "%foo" ~~ s/^'%'//; 11:57
camelia rakudo-moar 448f82: OUTPUT«Cannot modify an immutable Str␤ in block <unit> at <tmp> line 1␤␤»
psch m: say ($= "%foo") ~~ s/^'%'//;
camelia rakudo-moar 448f82: OUTPUT«「%」␤»
psch m: say (my $a = "%foo") ~~ s/^'%'//; say $a
camelia rakudo-moar 448f82: OUTPUT«「%」␤foo␤»
psch samcv: yes, or as you said /^\%/ should work to 11:58
+o
samcv kk
m: say (my $a = "%foo") ~~ s/^\%//; say $a
camelia rakudo-moar 448f82: OUTPUT«「%」␤foo␤»
samcv m: say "%foo" ~~ s/^\%//;
camelia rakudo-moar 448f82: OUTPUT«Cannot modify an immutable Str␤ in block <unit> at <tmp> line 1␤␤»
samcv m: my $a = "%foo"; $a ~~ s/^\%//; say $a 11:59
camelia rakudo-moar 448f82: OUTPUT«foo␤»
samcv ok
samcv what is the perl6 equivilent of this? open my $SAID_OUT, '-|', "perl", @said_args; 14:07
samcv basicaly opening a pipe to perl supplied with the arguments in the array @said_args 14:08
timotimo something with run and :in, i'd say. potentially have to flatten the @said_args array by spelling it |@said_args
samcv will that make it run concurrently with the current script or will it wait for it to finish? 14:09
geekosaur concurrently, with :in
since otherwise that would be useless
masak not entirely, if I understand correctly 14:10
I mean, if you know up-front exactly what inputs you're going to give, irrespective of any outputs that come back...
samcv i'm trying to look up info on :in but not having any luck 14:11
timotimo docs.perl6.org/type/Proc - this has more info
probably really needs a link from the page on routine/run to type/Proc
because that has some more examples with :in and :out 14:12
actually
not really an example with :in per se. just one with :in using a pipe from another run's :out
samcv does :in supply command line args though? 14:13
timotimo :in is only for specifying that you want an input pipe, it has nothing to do with the commandline args
RabidGravy no, run takes a list of command line arguments 14:14
samcv oh i don't want that
RabidGravy what do you want then?
timotimo i thought you wanted to open a pipe?
samcv run 'perl', @said_args, :out;
would that work?
timotimo oh, you only want the *out* pipe
samcv yeah
RabidGravy m: say run("perl", "-v", :out).out.slurp-rest;
camelia rakudo-moar bb52f8: OUTPUT«run is disallowed in restricted setting␤ in sub restricted at src/RESTRICTED.setting line 1␤ in sub run at src/RESTRICTED.setting line 14␤ in block <unit> at <tmp> line 1␤␤»
RabidGravy boo
timotimo you need to flatten the @said_args, i believe
samcv hmm
i can do that 14:15
samcv as long as i can supply command line args with spaces in them 14:15
some of the ARGV's have spaces in them and i need to make sure it's not seperated by space
geekosaur run does that. (shell would be the one that flattens into a string) 14:16
RabidGravy yes, it's a single slurpy, so you'd have "run('perl', | @args, :in)"
timotimo oh, do we allow a space there?
RabidGravy dunno, just my typing :)
samcv my $SAID_OUT = run ('perl', | @said_args, :out); Unexpected named argument 'out' passed in sub-signature of parameter @args 14:18
:(
timotimo you put a space after run before the ( 14:19
so you're passing a list as a single argument
samcv ah ok
gfldex lolibloggedagain: gfldex.wordpress.com/2016/09/25/th...s-are-lta/
timotimo and you get a Proc object out of the run command, not just the out pipe
the out pipe itself can be accessed by $result.out
gfldex: your keys are on fi-yah!
samcv and before i was doing: while ( defined (my $line = <$SAID_OUT> ) ) { 14:20
to process each line as the script spits it out, how would i process by line without waiting for script completion in perl6?
timotimo "for $proc.out.lines { ... }" 14:21
samcv where $proc would be $SAID_OUT ?
timotimo yeah
samcv cool :)
samcv for my $line = $SAIDOUT.out.lines { will work? 14:22
timotimo that doesn't mean what you think it means 14:22
but i think it'll "work"
RabidGravy m: my $p = run("perl",:in, :out); $p.in.say("print 1 + 1"); $p.in.close; say $p.out.slurp-rest 14:23
camelia rakudo-moar bb52f8: OUTPUT«run is disallowed in restricted setting␤ in sub restricted at src/RESTRICTED.setting line 1␤ in sub run at src/RESTRICTED.setting line 14␤ in block <unit> at <tmp> line 1␤␤»
timotimo except it'll only run a single iteration
RabidGravy gah, forgot about that 14:23
timotimo you ran into that 10 minutes ago! :D
RabidGravy I know, having a funny memory afternoon 14:24
timotimo samcv: "for my $line = $SAIDOUT.out.lines {...}" will create a scalar variable named $line, put the result of $SAIDOUT.out.lines into it and then iterate over that scalar variable. but a scalar will only run a single iteration, so you'll have one run of the body with $_ set to $line, which is the Seq that'll give you the lines when you iterate over its .list 14:26
psch plus it leaves $line in the same scope as the for itself, which i think we have in p5-to-6 pitfalls or something..? 14:27
'cause that might not be what you mean
timotimo it's 100% not what samcv means :) 14:27
samcv so is there a way other than my $line = $_ on the first line of the loop? 14:28
gfldex m: for my @a = lines() { $++ }; @a.elems.say
camelia rakudo-moar bb52f8: OUTPUT«20␤»
gfldex m: for my @a = lines() { .say }; @a.elems.say
camelia rakudo-moar bb52f8: OUTPUT«Céad slán ag sléibhte maorga Chontae Dhún na nGall␤Agus dhá chéad slán ag an Eireagal ard ina stua os cionn caor is coll;␤Nuair a ghluais mise thart le Loch Dhún Lúich’ go ciúin sa ghleann ina luí␤I mo dhiaidh bhí gleanntáin ghlas’ G…»
samcv so for $SAID_OUT.out.lines = my $line { ? 14:29
RabidGravy not really 14:30
psch samcv: well, for takes a Block, and anon Blocks get their signature after the pointy
m: say -> $a { } 14:31
camelia rakudo-moar bb52f8: OUTPUT«-> $a { #`(Block|59191480) ... }␤»
RabidGravy for $SAID_OUT.out lines -> $line { }
gfldex samcv: assignment to a @-sigiled container gets you one .flat-call for free.As a result it iterates properly
RabidGravy except I missed a dot
no I didn't 14:32
for $SAID_OUT.out.lines -> $line { }
samcv nice, okay that makes sense 14:33
RabidGravy anyhow, to repeat my earlier question, does anyone have a local clone of HTTP::Server::Tiny and want to offer any suggestions as to why the deadlock in t/12-supply.t? 14:38
timotimo RabidGravy: ??? "not really"?
RabidGravy eh?
timotimo i'm confused
psch probably lag-based line ordering mixup?
'cause it's perfectly sensible here 14:39
timotimo: irclog.perlgeek.de/perl6/2016-09-25#i_13278499
RabidGravy psch, are you on linux or something else?
timotimo i'm interpreting it as "is there a way ... ?" "not really" "here's how you do it"
psch RabidGravy: i'm on windows with putty to irc.p6c.org
RabidGravy: so, technically, "yes" 14:40
RabidGravy oh no, it was to "so <not worky thing>" :)
Hmm
that's very, very odd
timotimo oh
psch RabidGravy: my 3 lines about lag-based line ordering mixup were about timotimos confusion though :) 14:41
RabidGravy: i have no idea about HTTP::Server::Tiny
RabidGravy oh
dalek c: 03a21f8 | (Jan-Olof Hendig)++ | doc/Type/Parameter.pod6:
Added a few missing method definitions
16:22
gfldex is there a way for a trait_mod:<is>(Parameter:D \param, :$element-of) to add a where-clause to the parameter? 16:25
psch m: multi trait_mod:<is>(Parameter:D \param where *.sigil eq '$', :$element-of) { } # ? 16:31
camelia ( no output )
gfldex psch: i want to add a where-constraint by the trait_mod not on it 16:48
psch m: multi trait_mod:<is>(Parameter:D \param, :$element-of) { die if param.sigil ne '$'; ... } # ? 16:49
camelia ( no output )
psch gfldex: i think you cannot do things about the *value* of the Parameter though
gfldex psch: that would be run at compile time, where clauses are runtime things
psch gfldex: so, if i now finally understand your question correctly, you can't 16:50
m: say &trait_mod:<where>
camelia rakudo-moar bb52f8: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Undeclared routine:␤ trait_mod:<where> used at line 1. Did you mean 'trait_mod:<hides>', 'trait_mod:<is>', 'trait_mod:<handles>', 'trait_mod:<trusts>', 'trait_mod:<returns>'?␤␤»
psch gfldex: i mean, maybe you can somehow hack something together with Parameter.constraints and cargo-culting what we do internally for post constraints, but i'm pretty sure there's no clean and easy interface for that kinda thing 16:53
dalek c: 9e92433 | (Jan-Olof Hendig)++ | doc/Type/Parameter.pod6:
Added a few more method definitions and an example
18:22
tushar Is there any way to extract an element of each array from array of array? Ex: "my @a = [[1,2,3],[4,5,6]]". How can I extract second element from both the arrays i.e. [2,5]? Thanks. 18:27
FROGGS m: my @a = [[1,2,3],[4,5,6]]; say @a.map({ $_[1] }) 18:28
camelia rakudo-moar bb52f8: OUTPUT«(2 5)␤»
FROGGS tushar: ^^
FROGGS m: my @a = [[1,2,3],[4,5,6]]; my @b = @a.map({ $_[1] }); dd @b 18:29
camelia rakudo-moar bb52f8: OUTPUT«Array @b = [2, 5]␤»
FROGGS m: my @a = [[1,2,3],[4,5,6]]; my @b = @a.map(*.[1]); dd @b
camelia rakudo-moar bb52f8: OUTPUT«Array @b = [2, 5]␤»
tushar FROGGS: Thanks. 18:30
FROGGS: When you said ^^, you meant ^^ operator. Correct? 18:31
FROGGS no, I meant "look"
:o)
or even "look to what I wrote" 18:32
tushar haha.. got it..
gfldex m: my @a = [[1,2,3],[4,5,6]]; say @a[0,1][1] 18:32
camelia rakudo-moar bb52f8: OUTPUT«[4 5 6]␤»
gfldex m: my @a = [[1,2,3],[4,5,6]]; say @a[0;1,1;1][1] 18:33
camelia rakudo-moar bb52f8: OUTPUT«Index out of range. Is: 1, should be in 0..0␤ in block <unit> at <tmp> line 1␤␤Actually thrown at:␤ in block <unit> at <tmp> line 1␤␤»
gfldex m: my @a = [[1,2,3],[4,5,6]]; say @a[0,1;1,1]
camelia rakudo-moar bb52f8: OUTPUT«(2 2 5 5)␤»
gfldex m: my @a = [[1,2,3],[4,5,6]]; ssy @a[0,1;1,1]
camelia rakudo-moar bb52f8: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Undeclared routine:␤ ssy used at line 1. Did you mean 'say'?␤␤»
gfldex m: my @a = [[1,2,3],[4,5,6]]; dd @a[0,1;1,1]
camelia rakudo-moar bb52f8: OUTPUT«(2, 2, 5, 5)␤»
FROGGS m: my @a = [[1,2,3],[4,5,6]]; say @a[0,1;1]
camelia rakudo-moar bb52f8: OUTPUT«(2 5)␤»
FROGGS m: my @a = [[1,2,3],[4,5,6]]; say @a[*;1] 18:34
camelia rakudo-moar bb52f8: OUTPUT«(2 5)␤»
FROGGS though, .map is easier to explain and understand I'd say
gfldex tushar: see docs.perl6.org/language/subscripts...dimensions 18:37
tushar FROGGS and gfldex: Thanks.
dalek osystem: 22488ae | (Fernando Correa de Oliveira)++ | META.list:
Add ProblemSolver

  github.com/FCO/ProblemSolver
18:40
osystem: 90d5d51 | RabidGravy++ | META.list:
Merge pull request #253 from FCO/master

Add ProblemSolver
SmokeMachine____ :) 18:42
tushar FROGGS: What would you recommend if I would like to extract multiple elements as an array and make array of array out of them. Ex: " my @a = [[1,2,3],[4,5,6]]; say @a[*;0..1];". When I tried it, I got back flatten list. I can use map and push results into new array. I am just wondering is there any other way I can accomplish that? I hope that I am clear enough. 18:54
m: my @a = [[1,2,3],[4,5,6]]; say @a[*;0..1];
camelia rakudo-moar bb52f8: OUTPUT«(1 2 4 5)␤»
tushar what I would like to get "[[1,4],[2,5]]". 18:55
FROGGS m: my @a = [[1,2,3],[4,5,6]]; dd @a[*;0..1]; 18:57
camelia rakudo-moar bb52f8: OUTPUT«(1, 2, 4, 5)␤»
FROGGS hmmm
psch slices always flatten, don't they? 18:59
psch so you'd have to map that 19:00
mst m: my @a = [[1,2,3],[4,5,6]]; @a.map: *[0..1]
camelia ( no output )
FROGGS seems like...
mst m: my @a = [[1,2,3],[4,5,6]]; dd @a.map: *[0..1]
camelia rakudo-moar bb52f8: OUTPUT«((1, 2), (4, 5)).Seq␤»
mst that's not completely horrible 19:01
gfldex m: sub g($x where -> \x { fail X::AdHoc.new(payload=>'bad ' ~ x.VAR.name) }) {}; g(1) 19:02
camelia rakudo-moar bb52f8: OUTPUT«bad $topic␤ in any at /home/camelia/rakudo-m-inst-2/share/perl6/runtime/CORE.setting.moarvm line 1␤ in sub g at <tmp> line 1␤ in block <unit> at <tmp> line 1␤␤»
psch m: my @a = [[1,2,3],[4,5,6]]; dd [do [@a[$++;0,1]] for @a]
camelia rakudo-moar bb52f8: OUTPUT«[[1, 2], [4, 5]]␤»
psch that's at least a bit more horrible :P
FROGGS hehe
tushar haha.. 19:03
psch looks a bit like python, actually
tushar hahahaha 19:03
ugexe m: my @a = [[1,2,3],[4,5,6]]; dd [Z] @a; 19:04
camelia rakudo-moar bb52f8: OUTPUT«((1, 4), (2, 5), (3, 6)).Seq␤»
ugexe m: my @a = [[1,2,3],[4,5,6]]; dd ([Z] @a)[0..1]; 19:07
camelia rakudo-moar bb52f8: OUTPUT«((1, 4), (2, 5))␤»
tushar ugexe++ . How can I convert the resulted list of list to array of array i.e. [[1,4],[2,5]] . I have tried "my @a = [[1,2,3],[4,5,6]]; my @b = ([Z] @a)[0..1];" which gave me an array consisting of list. 19:14
m: my @a = [[1,2,3],[4,5,6]]; my @b = ([Z] @a)[0..1];
camelia ( no output )
tushar m: my @a = [[1,2,3],[4,5,6]]; my @b = ([Z] @a)[0..1]; @b.say;
camelia rakudo-moar bb52f8: OUTPUT«[(1 4) (2 5)]␤»
timotimo m: my @a = [[1, 2, 3], [4, 5, 6]]; say @a[0].WHAT 19:15
camelia rakudo-moar bb52f8: OUTPUT«(Array)␤»
timotimo it's already an array of arrays
psch ooh misread the question the whole time, ugexe++ 19:15
i mean, i did :) 19:16
tushar timotimo: I know that @a is array of array. I am how can i convert result of "([Z] @a)[0..1];" to array of array. It returns list of list. 19:19
ugexe m: my @a = [[1,2,3],[4,5,6]]; my @arr = ([Z] @a)[0..1]>>.Array; say @arr.perl # if thats what you *really* want 19:20
camelia rakudo-moar bb52f8: OUTPUT«[[1, 4], [2, 5]]␤»
SmokeMachine____ m: sub f([$a, *@a], [$b, *@b]) {gather {take [$a, $b]; if @a & @b { .take for f(@a, @b)}}}; .say for f([1,2,3], [4,5,6])[^2] # :P
camelia rakudo-moar bb52f8: OUTPUT«[1 4]␤[2 5]␤»
mst tushar: them being lists instead of arrays shouldn't I don't think be a problem?
psch: yeah, same here
ugexe++
tushar hmm 19:22
timotimo well, with lists you don't get scalar containers guaranteed, right?
tushar ugexe++ 19:24
dalek c: 6b99fb8 | (Zoffix Znet)++ | doc/Type/Baggy.pod6:
Improve Baggy.classify-list

  - List all possible mappers
  - Document multi-level classify will throw
21:22
dalek c: eee5cfa | (Zoffix Znet)++ | doc/Type/Baggy.pod6:
Improve Baggy.categorize-list

  - Document all mappers
  - Doocument throwage conditions
21:32
dalek c: b4575c9 | (Zoffix Znet)++ | doc/Type/Hash.pod6:
Document Hash.classify-list

Closes #916
21:55
dalek c: 782e000 | (Zoffix Znet)++ | doc/Type/Hash.pod6:
Document Hash.categorize-list

Closes #916
22:09
c: b234967 | (Zoffix Znet)++ | doc/Type/Hash.pod6:
Explain Hash.classify-list :&as argument
22:10
aod can someone help me with perl6 loops? 22:12
I saw in several places loops like this: for 1, 3..10 { .say }
timotimo that'll need flattening for the second half 22:13
m: .say for 1, 3..10
camelia rakudo-moar 922afd: OUTPUT«1␤3..10␤»
timotimo m: .say for 1, |3..10
camelia rakudo-moar 922afd: OUTPUT«1␤1..10␤»
timotimo whoops, hehe. precedence of operators
m: .say for 1, |(3..10)
camelia rakudo-moar 922afd: OUTPUT«1␤3␤4␤5␤6␤7␤8␤9␤10␤»
aod what about (1,3..10)?
timotimo same as just 1, 3..10 22:14
timotimo if you want all of it as a single iteration, you can do: 22:14
m: .say for (1,3..10),
camelia rakudo-moar 922afd: OUTPUT«(1 3..10)␤»
Juerd m: sub infix:<except> (@a, $b) { @a.grep: * !~~ $b }; for [1..10] except 2 { .say } 22:15
camelia rakudo-moar 922afd: OUTPUT«1␤3␤4␤5␤6␤7␤8␤9␤10␤»
aod ok. but I saw an example like 0,2..10 where only even numbers were generated> I think I saw it on a larry wall video
Juerd aod: That's with 3 dots
timotimo you need ... for that instead of ..
aod ahhh bingo! 22:16
Juerd m: say 1, 3 ... 10
camelia rakudo-moar 922afd: OUTPUT«(1 3 5 7 9)␤»
aod thanks a lot
I have another question
I saw something like for (1..10) -> $i { say $i } 22:17
timotimo yeah
grondilu (what a tease)
aod actually this for <123> ->$i { .print } 22:19
but I got "control flow error"
aod nvm I just saw my mistake 22:19
timotimo m: for <123> -> $i { .say } 22:20
camelia rakudo-moar 922afd: OUTPUT«(Any)␤»
timotimo m: for <123> -> $i { $i.say }
camelia rakudo-moar 922afd: OUTPUT«123␤»
MasterDuke m: for <1 2 3> -> $i { $i.say } 22:20
camelia rakudo-moar 922afd: OUTPUT«1␤2␤3␤»
aod for <1 2 3> -> $i { $i.say } works, but for <1 2 3> -> $i { .say } dowsnt 22:21
timotimo yeah
because .say is syntax for $_.say
if you have -> $i, it won't store the data into $_ 22:22
MasterDuke m: for <1 2 3> { .say }
camelia rakudo-moar 922afd: OUTPUT«1␤2␤3␤»
timotimo right, when you don't give it a ->, it'll be as if you had used "-> $i" 22:23
MasterDuke "-> $_" 22:24
timotimo sorry. yes
if you give it only -> { ... }, it'll be a block that takes no arguments. for will then call it with an argument and it'll promptly explode
m: for <1 2 3> -> { say "oh" }
camelia rakudo-moar 922afd: OUTPUT«Too many positionals passed; expected 0 arguments but got 1␤ in block <unit> at <tmp> line 1␤␤»
gfldex omgibloggedagain!!1! gfldex.wordpress.com/2016/09/26/i-...e-channel/ 22:48
also, the docs are LTA on where-clauses 22:49
aod guys how do I list available methods of an object? Like pythons dir? 22:50
timotimo you can call .^methods on it
aod cool thx
timotimo sometimes you'll get an error if you're going too deep into the metaobjects. then you can .map(*.name) to make things readable 22:51
aod ok, like ().^methods.map(*.name) 22:52
more readable
timotimo well, i mean it like this:
m: say Attribute.^methods
camelia rakudo-moar 922afd: OUTPUT«(<anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> <anon> compose apply_handles get_value set_value container readonly package inlined WHY set_why Str gist)␤»
timotimo hm, not quite
gfldex m: say "foo".^methods».&{ .name, .signature.perl }.join: "\n"
camelia rakudo-moar 922afd: OUTPUT«BUILD :(Str $: :$value = "", *%_ --> Nil)␤Int :(Str:D $: *%_)␤Num :(Str:D $: *%_)␤chomp :(Str:D $: *%_)␤pred :(Str:D $: *%_)␤succ :(Str:D $: *%_)␤simplematch :(Str $: $pat, *%_)␤match :(Str $: $pat, :continue(:$c), :pos(:$p), :global(:$g), :o…»
timotimo m: say BOOTAttribute.^methods
camelia rakudo-moar 922afd: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Undeclared name:␤ BOOTAttribute used at line 1␤␤»
timotimo *shrug* 22:53
gfldex aod: see the following how to detect the odd cases (some are very internal and don't provide introspection) github.com/perl6/doc/blob/master/u...methods.p6 22:54
aod Do you know the rationale behind the choice of ~ as concatenation intead of + in perl6? Im just curious
gfldex aod: sorry wrong link, github.com/perl6/doc/blob/master/u...g-types.p6 22:55
timotimo because operators are coercive in perl6
+ will always turn its arguments into numbers, ~ will always turn its arguments into strings
so you'll never get confused with number + string or string + number
gfldex it's very easy to get that wrong and very hard to have complete tests for it (in languages that overload + for string concat) 22:56
timotimo especially when you look at how - behaves in languages like javascript
aod ok like the weird NaN stuff in JS. But I think the + operator could work id both types were strings. Its just hard to look at ~ and not see it as "negate" 23:00
if both types 23:01
timotimo we think it's a good idea to have ~ separate from + 23:02
gfldex hardly ever use ~, most of the time interpolation works better 23:03
timotimo yeah
zengargoyle ~ is like a thread sewing strings together. :)
+ adds
timotimo if you prefer ++ for string concat, you can put "my &infix:<++> = &infix:<~>" at the top of your scripts 23:04
also, in perl5 you used . for string concat, not +.
geekosaur aod, in a language where string and number get conflated a lot, it makes a lot of sense to not require + to guess which one you intended
timotimo also, if the operator decides what the result will be, you don't have to look at what types come in to see what type comes out 23:05
aod ok. talking about interpolation, whats the difference between "$a" and "{$a}", if any? {$a} is new to me... 23:11
timotimo no difference 23:12
but you can put any code between the { }
aod oh executable code?
is it like eval? 23:13
timotimo no
gfldex no, it's simply a concat
timotimo it's like writing code into your program
gfldex m: say "a { 41 + 2} b";
camelia rakudo-moar 922afd: OUTPUT«a 43 b␤»
gfldex m: say "a { do $++ for 1..3 } b"; 23:14
camelia rakudo-moar 922afd: OUTPUT«a 0 1 2 b␤»
aod this code is executed at compile time or run time? 23:14
gfldex aod: see docs.perl6.org/language/quoting#In...lation:_qq 23:15
runtime
m: say "a { qx/wget www.google.com/ } b"; 23:16
camelia rakudo-moar 922afd: OUTPUT«qx, qqx is disallowed in restricted setting␤ in sub restricted at src/RESTRICTED.setting line 1␤ in sub QX at src/RESTRICTED.setting line 11␤ in block <unit> at <tmp> line 1␤␤»
gfldex m: say "a { qx/wget -O- www.google.com/ } b"; # maybe better that way
camelia rakudo-moar 922afd: OUTPUT«qx, qqx is disallowed in restricted setting␤ in sub restricted at src/RESTRICTED.setting line 1␤ in sub QX at src/RESTRICTED.setting line 11␤ in block <unit> at <tmp> line 1␤␤»
gfldex m: sleep 10; say now.Int; say "a { BEGIN now.Int } b"; 23:19
camelia rakudo-moar 922afd: OUTPUT«1474845591␤a 1474845581 b␤»
gfldex you can have it at compile time ofc, for many values of compile time
aod learning a lot. perl6 is mind blowing. Another question, why doesnt WHAT shows in ()^.methods 23:32
TimToady it's not really a method 23:33
gfldex aod: it's (kind of) defined in Mu. Or better it would be defined in Mu, if Rakudo would have a magic boot to strap. 23:43
aod: see the following to understand what Mu is for docs.perl6.org/language/typesystem...erl_6_Type
dalek c: a38e81a | gfldex++ | doc/Language/typesystem.pod6:
end the sentence
23:52
c: 57234e6 | (Zoffix Znet)++ | doc/Type/Code.pod6:
Document Code.of()
23:59