🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 8 June 2022.
Nemokosch m: dd (9, ) >>**>> (1 .. *) 07:30
camelia (9,)
Nemokosch m: dd 9 >>*>> (1 .. *)
camelia List on right side of hyperop of infix:<*> is known to be infinite
in block <unit> at <tmp> line 1
Nemokosch My question is simple: _why_
why does it fail when the generating end is one single element 07:31
lizmat Nemokosch: probably some trait on the operator 07:59
tellable6 lizmat, I'll pass your message to Nemokosch
Nemokosch I'm pretty sure this is either a bug or not documented 08:01
It should simply take the lhs value and use it like in the first, one-element list case
lizmat tend to agree with you 08:09
Nemokosch is there something like divmod? seems like I overestimated the usefulness of polymod 08:14
[18] > 92.polymod(1,2,6,24,120,720) 08:28
(0 0 4 7 0 0 0)
this result makes no sense anyway
what is that 7?
> In the first case, 120 is divided by 10 giving as a remainder 12, which is the last element. 08:30
it's not the remainder, it's the quotient... could this be comprehensible...
lizmat you'd have to ask Larry, as he came up with it and implemented it, afaik :-) 08:38
Nemokosch it does the opposite of what I'd like to have, apparently 08:41
the description could be better either way
lizmat doc PR's are always welcome! 08:42
Nemokosch what it seems to do is -> returns $n mod $current and replaces $n with $n div $current for the next calculation 08:43
92 mod 1 is 0, 92 mod 2 is also 0, 46 mod 6 is 4, 7 mod 24 is 7 and from that point on, $n reached 0
what I would actually need is the opposite 08:45
returning the div and calculating further with the mod
of course then it would be fed in reverse order
92 div 720 is 0, 92 div 120 is still 0, 92 div 24 is 3, 20 div 6 is also 3, 2 div 2 is 1 and $n reached 0 08:47
Voldenet polymod is useful for converting ints into human readable output 08:54
m: say reverse (123412346435).polymod(1024 xx Inf) Z~ <b k M G T>
camelia (114G 959M 189k 579b)
Nemokosch theoretically yes, practically it could be much better, frankly 08:59
the "polydiv" function I described would give the same result AND would work for my use case as well
Voldenet so… you want to turn 92 into (3 3 1)? 09:00
m: say 92.polymod(1..5).reverse
camelia (0 3 3 1 0 0)
Voldenet something like that
Nemokosch this looks merely coincidental, though. It should be 0 0 3 3 1 0 09:01
Voldenet starting from 720, eh
m: say 92.polymod(1..6).reverse
camelia (0 0 3 3 1 0 0)
Nemokosch other than that I don't see how 1..5 relates to descending factorials 09:02
I guess this is some algebraic identity at the end of the day 09:04
I'm not sure if polymod can always fake "polydiv" this way 09:06
also this is considerably less readable with regards to the problem
Voldenet Yes, it is considerably less readable 09:07
Nemokosch I'm counting factorials because I want to identify a permutation
I could imagine a combinatoric problem where the countings for consequent number of elements don't divide each other 09:09
Voldenet Yes, this will produce unique sequences for substantially large numbers I think 09:10
Nemokosch for the factorials, indeed it looks like this will give the right result, which is cool some way 09:12
Voldenet you can see polymod as representation of positional systems also 09:13
m: say 16.polymod(16 xx 5).reverse
camelia (0 0 0 0 1 0)
Voldenet m: say 64.polymod(16 xx 5).reverse
camelia (0 0 0 0 4 0)
Voldenet m: say 256.polymod(16 xx 5).reverse 09:13
camelia (0 0 0 1 0 0)
Nemokosch still I think 1. polymod should get a better description, perhaps with even more example usages 2. it would make sense to have a polydiv, if for no other reason, for the more transparent interface 09:14
yes, and I have the impression that as long as the given divisors, idk the mathematical term but all divide the previous divisors, polymod and polydiv do the same thing but backwards 09:16
Voldenet m: say ((((((4 * 3) + 3) * 3) + 1) * 2) + 0) * 1 09:19
camelia 92
lizmat PR's are welcome :-)
Nemokosch you know what is the other notoriously sadistic method? 09:20
toggle
Voldenet my fav still is ^fff^ operator 09:21
when I see it in the code, i hang for a few seconds
Nemokosch I tried to look into those, too 09:22
but I succeeded even less than with the toggle method
sometimes it's good to make a from-predicate-to-predicate cut on an infinite sequence
and toggle kinda sorta lets you do that
still I wouldn't say it's an optimal tool... 09:24
simply because the semantics isn't terribly suited for either this or any other problem I can think of
Voldenet m: for ^50 { .say if !.is-prime ^fff^ .is-prime } 09:26
camelia 1
9
10
15
16
21
22
25
26
27
28
33
34
35
36
39
40
45
46
49
Nemokosch blogs.perl.org/users/zoffix_znet/20...tions.html this post about polymod is pretty good btw
especially the "handmade" part I think 09:27
it actually says how it works
Voldenet I just remember it as seconds-to-date-algorithm, there's only one way to write that correctly 09:28
Nemokosch well, that's a good start to interpolate 🤠
What bothers me about it is that it's really used as a fake "polydiv" when most of the time we would care about the div values indeed 09:30
> m: say reverse (123412346435).polymod(1024 xx Inf) Z~ <b k M G T>
this was a really good illustration
we care about how many times the unit _is filled_, not _what is left_ 09:31
it's just a nice side effect that answering "what is left" is a way to the other question
Voldenet writing good docs for this may be surprisingly difficult 09:32
even though it's such a simple method
Nemokosch This is like Horner's division
like okay it's nice and elegant to write it from small numbers and the modulus towards the bigger numbers 09:33
but we are still interested in the quotients, starting from the big numbers
and if you have those braindead anglo-saxon units of measure that may not even divide each other 09:34
the Horner way may even fail
Voldenet with non-SI units you may also need to know current moonphase or length of user's beard (if present) 09:35
Nemokosch 🤣 09:38
anyway, there may be situations where you can't rely on the mods turning into divs
and frankly I don't know when you'd want actually the mods
lizmat and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2022/07/18/2022-29-hot/ 11:07
frost lizmat++ 11:08
lizmat pretty cool, thank you :-) 11:09
Nemokosch test test 13:40
tellable6 2022-07-18T07:59:12Z #raku <lizmat> Nemokosch: probably some trait on the operator
Nemokosch is wondering 13:41
it worked, lol
lizmat wonders what it is that worked 13:43
Nemokosch same but backwards... 13:44
lizmat ah, an irc to discord bot ? 13:45
Nemokosch I was just curious if Pidgin would support this ACTION stuff 13:47
[Coke] stackoverflow.com/questions/729453...de-warning - doesn't the suggestion here mean that when the deprecated thing is removed, the code will then stop working? 14:11
(as opposed to changing the code to avoid the deprection warning) 14:12
lizmat [Coke]: I guess hhmmmm 14:21
[Coke] ok. added a comment. Thanks 14:24
docs say "Rakudo provides a separate set of executables suffixed with a 'w' (rakuw.exe, rakudow.exe, ...) that are compiled as non-console applications. These do not spawn this console window. 14:26
but if I run "rakuw -e 'say 3'", it does output it.
grondilu m: grammar { token TOP { \# } } 14:37
camelia ===SORRY!===
Regex not terminated.
at <tmp>:1
------> grammar { token TOP { \# } }⏏<EOL>
Regex not terminated.
at <tmp>:1
------> grammar { token TOP { \# } }⏏<EOL>
Malformed regex
at <tmp>:1
------> grammar…
tellable6 2022-05-23T23:55:55Z #raku <Xliff_> grondilu: Donno. But sticking a guard on that would effectively kill the Failure.
grondilu m: grammar { token TOP { '#' } }
camelia ( no output )
grondilu m: grammar { token TOP { \\# } } 14:38
camelia ===SORRY!===
Regex not terminated.
at <tmp>:1
------> grammar { token TOP { \\# } }⏏<EOL>
Malformed regex
at <tmp>:1
------> grammar { token TOP { \\# } }⏏<EOL>
grondilu I thought I could backslash # like with any metacharacter 14:39
m: grammar { token TOP { \% } }
camelia ( no output )
grondilu looks like a bug tbh
btw it works fine in a regex 14:40
m: say "#" ~~ /\#/
camelia 「#」
SmokeMachine m: my Pair $a = abc => 42; multi bla(Pair (:$key, |)) { say $key }; bla $a # this works... 17:11
camelia abc
SmokeMachine m: my Pair $a = abc => 42; given $a { when Pair (:$key, |) { say "bla" } } # Should this also work? 17:12
camelia ===SORRY!=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> air $a = abc => 42; given $a { when Pair⏏ (:$key, |) { say "bla" } } # Should thi
expecting any of:
block or pointy block
infix
SmokeMachine m: my Pair $a = abc => 42; given $a { when :(Pair (:$key, |)) { say "bla" }; default { .say } } # This does not die... 17:20
camelia abc => 42
SmokeMachine is there a better way of doing something like this? usercontent.irccloud-cdn.com/file/...6%402x.png 18:28
lizmat m: role Maybe[::T = Int] { } 18:33
camelia ( no output )
lizmat assuming role Maybe { } has Int as a default for T ? 18:34
SmokeMachine I don't know if it should have a default... 18:37
lizmat then what is the role of role Maybe without T ? 18:39
SmokeMachine just for be able to use Maybe without [T] on pattern matching 18:39
lizmat m: role Maybe[::T?] { } 18:41
camelia ===SORRY!=== Error while compiling <tmp>
Malformed parameter
at <tmp>:1
------> role Maybe[::T⏏?] { }
expecting any of:
constraint
formal parameter
lizmat m: role Maybe[::T = Any] { }
camelia ( no output )
lizmat that should allow it?
SmokeMachine lizmat: yes, thanks! usercontent.irccloud-cdn.com/file/...2%402x.png 18:43
lizmat yuu're welcome :-) 18:45
melezhik hi jjatria - did you get a chance to take a look at postfix + Tomtit PR? 19:06
habere-et-disper Z appears to have a default of the list constructor Z, (Z comma) 22:41
Should R have the same (it appears to not have a default)
? 22:42