🦋 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.
metagib Hi, i forget how to know if a number is an integer, my approach was this 00:58
"100.sqrt ~~ Int" #It's false, i but need to know if the result is an integer
metagib Also the bridge in the discord bot doesn´t work since more of three weeks 01:05
moon-child m: sub integral($x) { $x == $x.Int }; print integral 100.sqrt 01:10
camelia True
moon-child actually it should be sub integral($x) { ?try { $x == $x.Int } } 01:11
metagib Nice, i remember a specific method inside the lenguaje but maybe never existed lol 01:25
m: sub isint(Numeric $number) {$number == $number.Int}; say isint 100.sqrt 01:26
camelia True
metagib why the second option with try ? how is different to the first  one ? 01:27
moon-child m: sub integral($x) { $x == $x.int }; print integral 2i 01:28
camelia No such method 'int' for invocant of type 'Complex'. Did you mean any
of these: 'Int', 'UInt'?
in sub integral at <tmp> line 1
in block <unit> at <tmp> line 1
moon-child m: sub integral($x) { $x == $x.Int }; print integral 2i
camelia Cannot convert 0+2i to Int: imaginary part not zero
in sub integral at <tmp> line 1
in block <unit> at <tmp> line 1
moon-child m: sub integral($x) { ?try { $x == $x.Int }}; print integral 2i
camelia False
moon-child (you need the ? to coerce to a boolean, otherwise it returns Nil} 01:29
metagib Ohh nice, i dont consider the imaginary roots 01:34
thanks !!! 01:35
japhb 🎉‭🎉‭🎉‭ MUGS 0.0.6 is now released and uploaded. :-D 07:39
notagoodidea I am gonna pull a PR for the countdown stuff from Ben Hoyt somewhere today (simple and optimized) any modification to enhance it is welcome (in particular the optimized version) 08:17
CIAvash weekly: www.raku-lang.ir/en 12:30
notable6 CIAvash, Noted! (weekly)
lizmat CIAvash: looks nice, but how is it intended? as a proposal? a demo ? 12:41
CIAvash lizmat: It was a proposal a year ago when I opened an issue for it on problem-solving, but now it's an alternative website. But the community still can use the source code for creating a new site if they want to. 12:46
lizmat weekly: lizmat: It was a proposal a year ago when I opened an issue for it on problem-solving, but now it's an alternative website. But the community still can use the source code for creating a new site if they want to. 12:47
notable6 lizmat, Noted! (weekly)
lizmat so I won't forget :-)
afk&
notagoodidea github.com/benhoyt/countwords/pull/74 here it is. 12:48
it's nothing special but hey why not.
codesections m: (^9).classify({$_ %% 2 ?? :{:first<hash>:2k} !! :{:second<hash>:2k}}, :into(my %h{Hash})) 13:00
camelia Type check failed in binding to parameter 'key'; expected Hash but got Pair (:k(2))
in block <unit> at <tmp> line 1
codesections what am doing wrong ^^^^ ? 13:01
This looks like it should construct a %h Hash with Hash keys. But the keys are turned into Pairs somehow? 13:02
codesections m: say :{:first<hash>:2k}.WHAT 13:04
camelia (Hash[Mu,Any])
codesections it _should_ be a Hash...
oh, I guess the fact that a Hash is an Iterable is confusing things? 13:12
codesections actually, I'm just having difficulty with _any_ way of using Hashes as Hash keys 13:50
codesections m: my %h{Hash}; %h{ %(:k1<v1>:k2<v2>) } = 42 13:51
camelia Type check failed in binding to parameter 'key'; expected Hash but got Pair (:k1("v1"))
in block <unit> at <tmp> line 1
moritz camelia: that's because hashes are not a value type
erm, meant codesections
codesections reading the docs on that now. 13:52
ty
codesections moritz: does that mean that only value types can be used as Hash keys? 13:53
moritz yes 13:57
codesections But I can use a List of Pairs as a key. Lists aren't value types either, are they? 13:58
Or does immutability mean they are?
moritz m: say (1, 2, 3).WHICH 14:00
camelia List|73990384
moritz hm, looks more like a ref type to me
but I think lizmat did some of work on that some time ago, maybe she knows? 14:01
codesections m: my %h; %h{ (:k1<v1>:k2<v2>).Map } = 42; 14:05
camelia ( no output )
codesections m: my %h; %h{ (:k1<v1>:k2<v2>).Map } = 42; %h.keys.map: {.WHAT.say}
camelia (Str)
(Str)
codesections m: my %h := :{ (:k1<v1>:k2<v2>).Map = 42}; %h.keys.map: {.WHAT.say} 14:06
camelia Type check failed in binding; expected Associative but got Block (-> ;; $_? is raw = O...)
in block <unit> at <tmp> line 1
codesections m: my %h := :{ (:k1<v1>:k2<v2>).Map => 42}; %h.keys.map: {.WHAT.say} 14:07
camelia (Map)
codesections there we go... 14:07
codesections m: my %h := :{ (:k1<v1>:k2<v2>).Hash => 42}; %h.keys.map: {.WHAT.say} 14:07
camelia (Hash)
codesections moritz: ^^^ it looks like I can use Hashes/other ref types as keys just fine -- just not as a constraint? 14:09
codesections m: my Hash $h = :{ (:k1<v1>:k2<v2>).Hash => 42}; $h.keys.map: {.WHAT.say} 14:11
camelia (Hash)
codesections (also seems to work with assignment, not just binding) 14:12
xinming SmokeMachine: I think I just now found a bug, where when we try to save the Blob col type, Red will try to concat the Blob to Str with ~ operator. 15:30
SmokeMachine xinming: would you mind to open an issue with an example of code for that, please? 15:39
xinming SmokeMachine: Ok, creation worked, while calling .^save will raise exception. 15:41
xinming hmm, ignore me, It seems, It's because of wrong type of column, after I changed column to other type, I can't seem to reproduce the bug 15:56
codesect` xinming: That sounds a lot like this issue: docs.raku.org/language/traps#Using...t_of_blobs 15:58
[Coke] wonders how having a hash as a key is helpful. 17:07
That is, what's the use case?
[Coke] if I run 'zef install MUGS' I get as far as "===> Searching for missing dependencies: RPG::Base, Cro::WebApp, Term::termios, Text::MiscUtils::Layout, Pluggable" and then it hangs. 18:19
(trying again with --verbose)
[Coke] ... maybe the new 0.0.6 release just now fixed it? install proceeding 18:24
[Coke] (can't easily see the old version I tried to install, it scrolled off) 18:25
QhpAptyj9hj0RQwM [Coke]: Did the install complete? 18:49
[Coke] no. ended up getting a segfault instead 18:51
QhpAptyj9hj0RQwM [Coke]: Hmm. What OS are you running, and how did you install zef?
QhpAptyj9hj0RQwM That way I might be able to recreate the issue on my end :) 19:03
moon-child curious, why is there no builtin infix operator for appending lists? 19:09
e.g. infix:<..>(@a, @b) { |@a, |@b }
codesections m: my @a = <0 2 6>; my @b = <7 8 9>; @a ,= @b; say @a 19:10
camelia (\Array_58686824 = [Array_58686824 [7 8 9]])
codesections er, 19:11
moon-child ooh, I didn't know there was prettyprinting for circular data structures 19:12
that's neat
codesections the below behavior is a bug, right? 21:00
m: sub f(:$named) {dd $named}; f(:named('k1' => (:pair<list>:done<right>), 'k2' => :pair<list>:done<wrong>)) 21:01
camelia $(:k1((:pair("list"), :done("right"))), :k2(:pair("list")))
codesections I know there's a syntax error -- the second pair list should be inside parens. But that should result in the Signature not matching, right? Not just silently disappear... 21:02
moritz I think it's applied as an adverb somewhere... but TBH this is something I never managed to wrap my head around 21:04
moritz adverb like in the %hash<key>:delete access 21:04
codesections hmm, I thought that implemented through named parameters. Hold on, I just read something about that 21:06
perl6advent.wordpress.com/2013/12/...y-adverbs/ 21:07
m: sub f(:$named, *%h) {dd $named; dd %h}; f(:named('k1' => (:pair<list>:done<right>), 'k2' => :pair<list>:done<wrong>)) 21:12
camelia $(:k1((:pair("list"), :done("right"))), :k2(:pair("list")))
Hash element = {}
codesections if it's turning into an adverb, then in theory it should show up in the slurpy, right?
moon-child is there a way to do ioctls in raku (without nativecall)? docs.raku.org/language/5to6-perlfunc#ioctl indicates no dice, but maybe that's out of date? 21:21
moritz codesections: it might be an adverb to the pair constructor, which ignores it? 21:22
codesections moritz: Oh, good thought. 21:23
moritz perlpunks.de/paste/show/60527389.2f5c.1fc 21:24
the QAST::WVal+{QAST::SpecialArg}(Str :named<c>) <wanted> d in the argument list of the .new call seems to support this hypothesis 21:25
codesections so does 21:26
m: say Pair.^lookup('new').signature
camelia (Pair: |)
codesections m: say Pair.^lookup('new').candidates.map: *.signature 21:27
camelia ((Pair: Cool:D \key, Mu \value, *%_) (Pair: Mu \key, Mu \value, *%_) (Pair: Mu :$key!, Mu :$value!, *%_))
codesections m: say &infix:«=>».candidates.map: *.signature 21:28
camelia ((Mu $key, Mu \value))
codesections yep, moritz, you were right. So that just leaves the question of whether it's a bug or not 21:29
moon-child m: my uint8 $x = 0; print +^ $x; 22:37
camelia -1
moon-child hmmm...
on my system, that prints 'Cannot invoke this object (REPR: P6opaque; NQPMu)'. Either way, I want it to return 255 instead of coercing to a regular Int. Is there a way to do that?
codesections moon-child: I'm pretty sure there are some bugs in our uint code atm: github.com/rakudo/rakudo/issues/3936 22:42
m: my uint8 $x = 0; print (my $ = +^ $x) 22:44
camelia -1
codesections m: my uint8 $x = 0; print (my $ = +^$x)
camelia -1
codesections m: my uint8 $x = 0; print (my $ = +^ $x<>)
camelia -1
moon-child m: my uint8 $x = 0; print (my $ := +^$x)
camelia -1
codesections m: my uint8 $x = 0; print (my $ = +^ 0) 22:45
camelia -1
codesections m: my uint8 $x = 0; print (my uint8 $ = +^ $)
camelia Use of uninitialized value of type Any in numeric context
255 in block <unit> at <tmp> line 1
moon-child :/ 22:46
codesections m: my uint8 $x = 0; print (my uint8 $ = +^ $x)
camelia 255
codesections ...which is actually what I *meant* to type the first time...
moon-child hmmm, I still get this error 'Cannot invoke this object (REPR: P6opaque; NQPMu)' 22:55
with the latest git
(aside: anyone know why the makefile opts to install into a local dir instead of system-wide?)
codesections Odd, I don't get that error on release or git (though I haven't built it in a few days) 22:58
I don't know the reasoning for the Makefile, but I like to keep the dev version in its own folder and run release for other work, so I'm fine with it. 22:59
But you can set a different one with an argument to the ./configure script 23:00
moon-child reverted to the same commit hash as the bot; same result 23:07
weird
guess I'll have to make my utf8 decoder less clever then
japhb Why do a utf8 decoder? It's built in ... 23:08
moon-child I'm making a repl, so it needs to read a character at a time. And builtin getc has one character of buffering, for combining characters, which I can't find out how to disable 23:09
so, I don't actually need to do the decoding myself, but I need to know how many continuation bytes to fetch
japhb moon-child: Oh, I have a solution to that. 23:17
github.com/ab5tract/Terminal-Print...wInput.pm6 or github.com/ab5tract/Terminal-Print...dInput.pm6 or github.com/Raku-MUGS/MUGS-UI-CLI/b...ut.rakumod (all of which I wrote at various times and for various needs) 23:18
The first one just allows you to get raw input that hands you data as soon as there are enough utf8 bytes to decode, and importantly *WITHOUT* waiting for combining characters. 23:20
The second one decodes escape sequences and special keys streaming from the RawInput supply.
The third one is a start on a Linenoise/ReadLine replacement that isn't as broken as Linenoise is, nor nearly as large/complex as Readline. 23:21
moon-child hmmm, I already wrote the function and basic escape decoding, but might steal some of your code there 23:22
japhb It's worth knowing BTW, that it's safe to concatenate strings ending with base characters with strings starting with combining characters -- MoarVM automatically does NFG fixups to make the string normalized afterwards.
moon-child ahh, that's good to know 23:23
japhb moon-child: One useful bit is that the third one (the Linenoise replacement) is the first one with code to multiplex querying the terminal and reading input. 23:25
Which is useful for determining where the cursor actually is, how big the terminal is, etc. 23:26
japhb The biggest limitation of the Linenoise replacement is that I hadn't added escape sequence decoding yet (nor history search, tab completion, or hints, but those aren't fundamental to the input question you seemed to have) 23:32
moon-child tab completion will be a pain. I want to do what zle does and show the completions below the prompt (without making a new one, like bash does), but that seems somewhat involved 23:33
japhb ... which is pretty much why I hadn't yet split it out of the MUGS codebase and released it separately, though that's likely at some point; Linenoise is just too broken around ANSI and non-latin alphabets.
moon-child I think someone did a linenoise that handled utf8
japhb As far as I could tell, that project got abandoned ... and I doubt it was ever as Unicode-smart as Raku is out of the box. 23:34
moon-child few things are as unicode-smart as raku is out of the box :P 23:35
japhb The tab completions on a different line thing are why being able to query the terminal while accepting input is very useful. ;-)
But the other problem is that Linenoise is utterly unaware of ANSI sequences in the prompt (despite using them for terminal control). Which means if you like to highlight your prompts ... Linenoise will happily screw things up as soon as you backspace at start of input. 23:36
moon-child it also doesn't support multiline editing or input
japhb Also Linenoise can't understand not havin the full display width to work with. So if you want to keep your input line inside a frame, well ... SOL. 23:37
Yeah, it does long line input. Sorta. But not multiline.