🦋 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.
uzl[m] I've created the following section(?) (gist.github.com/uzluisf/7f575c7023...565b2db40) to complement the other section on the `handles` trait . I'm unsure if it meets the standard for the docs but if it does, I can submit a PR to include it. I was thinking it'd be a nice addition to the Objects page. 04:01
AFK
[Coke] . 04:30
synthmeat if FatRat is infectious, why does this break on line 6? gist.github.com/synthmeat/635fdda6...9b3ce81dd6 13:21
thundergnat synthmeat: As it is, it breaks because $_ is undefined. 13:41
tellable6 2020-02-08T20:06:22Z #raku <Doc_Holliwould> thundergnat: Ty, that is a nice way. I did not know about this function.
synthmeat thundergnat: ok, good catch, but even without it gist.github.com/synthmeat/635fdda6...9b3ce81dd6 13:45
thundergnat Yeah, there is something else going on there, I'm looking at it. 13:46
synthmeat it isn't infectious as exponent? 13:51
thundergnat synthmeat: Ok, that is a little unintuitive but yeah, FatRat exponents aren't infectious 13:52
thundergnat Change it to: $sum += FatRat.new(1 , 2 ** $n++); and it works how I would expect 13:53
synthmeat yeah, that's what it says in the book. was just wondering why this wasn't working too. ty ^_^
thundergnat At first glance, I was quite puzzled too.
synthmeat doesn't even work when both base and exponent are fat rats 13:55
thundergnat Without going and digging around in the source, I suspect that exponentiation only has Num and Int candidates 13:56
synthmeat yeah, "The exponentiation operator coerces both arguments to Numeric and calculates the left-hand-side raised to the power of the right-hand side." 13:57
thundergnat If you want to operate on FatRats: github.com/SqrtNegInf/Rosettacode-...utines#L50 Lines 50-90 13:58
synthmeat nice. i'll give it a proper look once i'm up to speed with raku in general 14:00
synthmeat (quite some fun all this raku so far!) 15:10
benlittle p6: say "x" ~~ rx:r/ <-[-]>+ %% <.ws>+ (.*) /; 17:00
camelia (signal XCPU)
benlittle Any idea why that regex hangs?
leont Because <ws> can be zero width 17:01
benlittle Is there a canonical way to alternate whitespace without running into zero width issues? The only way I know of is to redefine the <ws> token 17:03
leont I think you want to use something other than <ws> 17:05
moritz you don't need to quantify <.ws> with a +
it matches more than one blank anyway
m: ' ' ~~ /<ws>/ and say $/.Str.chars
camelia 3
leont You probably want to use <.space>+
<.ws> is closer to <.space>* 17:06
moritz or \s+
leont Eh, yeah that's the more logical way to write that 17:07
benlittle Right on 😃 17:08
leont I remember being bitten exactly by this myself at some point, it's not entirely obvious
Skarsnik Hello, what is the best way to compare data in a Buf inside test? when using just ok I get an error that it can't stringify one buf, but is-deeply fail when comparing Buf and Buf[uint8] 17:15
tellable6 2019-07-09T11:54:10Z #perl6 <timotimo> skarsnik: did you see that gumbo has probably been fixed?
Skarsnik July 2019, you are kinda late tellable6 ! 17:16
/using just ok/using just is/ 17:19
sena_kun Skarsnik, can you golf it a bit? 17:21
m: use Test; say is Buf.new(42), Buf[uint8].new(42);
camelia ok 1 -
True
Skarsnik let see 17:25
Skarsnik m: use Test; is Buf.new([0 xx 40]), Buf.new([1 xx 40]); 17:26
camelia not ok 1 -
# Failed test at <tmp> line 1
Cannot use a Buf as a string, but you called the Stringy method on it
in block at /home/camelia/rakudo-m-inst-2/share/perl6/core/sources/2D4A7CA10695CD2B374573413D261A660E282E2A (Test) line 188
in…
Skarsnik that what I get when the test fail instead of expected: blabla, got: claclalca 17:27
sena_kun oh, I see where I'm wrong
Geth ecosystem: 35308e509d | thundergnat++ (committed using GitHub Web editor) | META.list
Add String::Splice to the ecosystem

See github.com/thundergnat/String-Splice
Skarsnik m: use Test; is Buf.new([0 xx 40]), Buf.new([0 xx 40]); 17:28
camelia ok 1 -
sena_kun Skarsnik, I'd convert it to Blob, to be honest
I think we have such tests in Cro
it isn't too pretty, of course
Skarsnik feel like Test/rakudo bug x) 17:29
sena_kun maybe Test should not attempt to use .Str, using .gist instead
Skarsnik ? Str look fine, just why it fail when data are not the same 17:30
sena_kun Skarsnik, no, I mean...
thundergnat Skarsnik: Do you get the same failure if you do a is-deeply() rather than is()? 17:31
sena_kun the thing is that when the comparing fails, it tries to show you expected/got message and apparently uses .Str method on Buf to stringify it, but Buf wants decode. Using .gist instead of .Str might be better, but I am not really pro.
Skarsnik, can you file a ticket, please? 17:32
Skarsnik is-deeply fail correcly, just it's annoying because my test data are from a file and slurp give me a buf8 and my data are Buf
Skarsnik so it fails because type are not the same ^^ 17:32
thundergnat is() is really geared toward string comparisons, so things that aren't strings can fail in weird ways 17:33
Skarsnik m: say Buf.new(<1 2 3>).gist; say buf8.new(<1 2 3>); 17:34
camelia Buf:0x<01 02 03>
Buf[uint8]:0x<01 02 03>
Skarsnik sena_kun, it's in rakudo/rakudo issues to fill a ticket now?
sena_kun Skarsnik, yeah, github.com/rakudo/rakudo/issues 17:35
thundergnat m: open( $*IN, :bin); say .slurp;
camelia No such method 'slurp' for invocant of type 'Any'
in block <unit> at <tmp> line 1
rypervenche I've got a list of hashes. I want to do a for loop and loop through and create a string from each hash and then have that string end in a newline. I'd like to have the output of that for loop essentially be a string with one string on each line, each line ending in a new line and be put in a variable. How might I accomplish that? I can do it using my $var = do for... but I can only manage to get it
to work using "say", but it doesn't go into the variable.
sena_kun rypervenche, let's see... 17:36
rypervenche I can show what I have, so it might make more sense.
sena_kun m: my %a = a => 1, b => 2; my $str = %a.map({ "$_.key() is $_.value()" }).join("\n") ~ "\n"; say $str; 17:37
camelia a is 1
b is 2
sena_kun rypervenche, something like this?
Skarsnik sub buf-is {is $buf1.Str, $buf2.Str, $msg}; could that work? x) the issue is probably to redirect the error of the is to the line of buf-is
rypervenche Oh, I completely forgot about join. 17:38
sena_kun Skarsnik, no, this won't work, Buf are not .Str. And that's the issue with `is` you have.
leont has been planning a feature to do that redirecting, but hasn't gotten around to that
rypervenche I'm converting a really old db file, which is '| ' delimited to a \0-delimited one: gist.github.com/rypervenche/0834f7...d2b38f0744 17:39
I think join will do exactly what I need. I completely forgot about that.
sena_kun m: say Buf.new(1,2,3).Str;
camelia Cannot use a Buf as a string, but you called the Str method on it
in block <unit> at <tmp> line 1
Skarsnik duh
sena_kun m: use Test; ok Buf.new(1) eq Buf[uint8].new(1); ok Buf.new(0) eq Buf[uint8].new(1); 17:40
camelia ok 1 -
not ok 2 -
# Failed test at <tmp> line 1
sena_kun if you don't really care about what's the difference, you can do ^, otherwise a ticket (though even if there will be a fix, it means it'll have to go into a release and then be fresh enough and) 17:41
Skarsnik oh right, it compare with eq then fail to .Str to show what is wrong
sena_kun yesh
Skarsnik Not sure how to formulate the issue xD 17:44
sena_kun Skarsnik, "Buf comparing dies when using `is` Test subroutine" 17:45
Skarsnik, and then provide a sample of what's happening (you know, this "It compares ok, but dies in attempt to do .Str to provide failure message") and "It shouldn't die, instead should just mark this compare is nok". 17:46
Skarsnik Everytime I touch Raku I found some bugs/annoying behavior x 17:48
another bugs to report: the issue template should maybe be updated for raku xD it says * Compiler version (`perl6 -v`): 17:49
benlittle p6:grammar Test { token TOP { <x>+ % \h+ [\N*] \n } proto token x {*} token x:sym<A> { \S+ [\h \S+]* } token x:sym<B> { "[" <special-token> "]" <.ws> <important-message> } token special-token { "SPECIAL TOKEN" } token important-message { \S+ }}my $dat = q:to/EOF/;59.5 Some Term [SPECIAL TOKEN] Important!! Yet 17:50
another termEOFsay Test.parse($dat);
evalable6 (exit code 1) 04===SORRY!04=== Er…
benlittle, Full output: gist.github.com/f1824bcc7894f9b973...56be2854b0
rypervenche Nice. .join fixed my issue and I was able to do it all in my grammar's actions. :) 17:52
Skarsnik m: 'class A { method get-tab returns Array[A] {my A @t; @t.append(A.new); return @t} }; multi sub infix:<(elem)>(Str $stuff, A @d) { say "my infix" }; my $a = A.new; my @tab = $a.get-tab; say "foo" (elem) @tab;' 17:57
camelia WARNINGS for <tmp>:
Useless use of constant string "class A { method get-tab returns Array[A] {my A @t; @t.append(A.new); return @t} }; multi sub infix:<(elem)>(Str $stuff, A @d) { say \"my infix\" }; my $a = A.new; my @tab = $a.get-tab; say \"foo\"…
Skarsnik m: class A { method get-tab returns Array[A] {my A @t; @t.append(A.new); return @t} }; multi sub infix:<(elem)>(Str $stuff, A @d) { say "my infix" }; my $a = A.new; my @tab = $a.get-tab; say "foo" (elem) @tab;
camelia False
Skarsnik it's annoying to have to write my A @tab to have the right infix called. I know the compiler does not check method type to solve type 17:58
moritz that's the downside of using nominal types over structural types 18:01
Skarsnik maybe there should be a pragma to force the compiler to check method type and such, I am pretty sure 99% of code written by people does not compose much/change a class at run time x) 18:03
Skarsnik 1..10 good enought for today x) 18:15
Doc_Holliwood Any of you guys do work in Swift? 18:45
rypervenche How might I supply a string to a command's STDIN using "run"? I've tried following the docs on run, but I haven't been able to find the right combination of things. 20:48
I'd like to do something like this: run «gpg -c -o "$new-encrypted-db"», :in($passwords); where $new-encrypted-db is the output file and $passwords is a string.
leont If you specify :in, then the proc object will have an $proc.in member that you can write to 21:00
rypervenche leont: Ahh, thank you. I understand it better now. I had to assign the Proc object(?) to a variable and then do $p.in.say: $passwords; and then $p.in.close; That did the trick :) 21:23