This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html Set by lizmat on 8 June 2022. |
|||
greenfork | Is this OK that with this signature: `multi sub infix:<mod>(Int:D $a, Int:D $b --> Int:D)`, I can do the following | 11:53 | |
m: say 10.3 mod 3.3 | |||
camelia | 0.4 | ||
greenfork | And this is equivalent to | ||
m: say 10.3 % 3.3 | |||
camelia | 0.4 | ||
lizmat | m: dd (10.3).WHAT | 11:54 | |
camelia | Rat | ||
lizmat | m: dd (10.3).WHAT ~~ Int | ||
camelia | Bool::False | ||
lizmat | greenfork: a Rat is not an Int, so that signature will not be selected | ||
greenfork | Documentation says: Integer modulo operator. Returns the remainder of an integer modulo operation. | 11:57 | |
docs.raku.org/language/operators#infix_mod | |||
I'm confused why it says "Integer" | |||
lizmat | greenfork: this appears to be a recent change: github.com/Raku/problem-solving/issues/326 | 12:02 | |
that apparently didn't make it to the documentation yet | |||
greenfork | I see, thank you! | 12:06 | |
lizmat | having said that, it feels that: | 12:09 | |
m: say 10.3 mod 3.3 | |||
camelia | 0.4 | ||
lizmat | is wrong, I'd expect it to produce 1, like | 12:10 | |
m: say 10 mod 3 | |||
camelia | 1 | ||
lizmat | as opposed to % | ||
m: say 10.3 % 3.3 | |||
camelia | 0.4 | ||
greenfork | I agree, if mod and div are similar, then the behavior should be like for div | 12:15 | |
m: say 10.3 / 3.3 | |||
camelia | 3.121212 | ||
greenfork | m: say 10.3 div 3.3 | ||
camelia | 3 | ||
lizmat | greenfork: you might want to re-open or make a new problem solving issue for that: github.com/Raku/problem-solving/issues/326 | 12:22 | |
greenfork | lizmat: I will do so, sure | 12:24 | |
lizmat | ++greenfork | ||
greenfork | lizmat: I added a comment to the same issue, but I can't re-open it | 12:50 | |
lizmat | reopened now, thanks! | 12:51 | |
13:22
user1729 joined
|
|||
user1729 | Hi, quick question, what's the raku way / equivalent of developer.apple.com/documentation/...x(while:)? Can of course write something, but feels like the sort of thing raku'd have built in | 13:24 | |
lizmat | docs.raku.org/type/Any#method_toggle perhaps ? | 13:26 | |
user1729 | Ah, yup, that'll work. Thanks. I don't imagine I'd have come across that with what I was searching for in the documentation | 13:34 | |
lizmat | perhaps someone should write a Go -> Raku nutshell guide :-) | ||
user1729 | A migartion guide covering an entire standard library would be quite the task | 13:42 | |
lizmat | agree... :-) | ||
14:27
vlad joined
|
|||
rcmlz | @antononcube - would that be to conpkex to ask LLM for? Will an LLM come up with all the toggle/snatch/snitch/rotor/categorize/25-strange-things-more stuff you do not find easily in other languages? | 14:48 | |
antononcube | @rcmlz I have done a few experiments with that -- YMMV, a lot! | 14:51 | |
@rcmlz Basically, converting simple Python libraries to Raku works, but you still have to correct/change between 5% to 20% of the generated code. Converting Raku librarires to Python also kind of, sort of works. Again, manual changes are needed. | 14:53 | ||
I think it really depends on the problem domain. In a few cases, I was considering not converting an existing library to Raku, but make a new Raku library for the same functionalities from scratch using LLM-support. | 14:54 | ||
Over-developed Python libraries are hard to convert. I could not easily convert into maningful -- to me -- Raku code Python LLM libraries released by OpenAI, Google, or MistralAI. | 14:56 | ||
14:57
user1729 left
|
|||
rcmlz | ChatGPT proposes a grep based solution. Probability nit enough toggle-solutions in the trainingdata …. :-( chat.openai.com/share/85f7f602-3c3...26ff6201e5 | 15:00 | |
lizmat | yeah, toggle is pretty new | ||
grep will work, with a "last" if you're done | |||
rcmlz | But interestingly it got it right, after explicitly asking for toggle. „The toggle method is useful for iterating over a sequence and collecting elements until a condition becomes false.“ | 15:03 | |
antononcube | @rcmlz Sorry, I answered a different question it seems. I read the statement: > A migration guide covering an entire standard library would be quite the task as : > A migration converting an entire standard library would be quite the task | 15:06 | |
I guess, I just needed an excuse to talk about LLM-conversions of software libraries. 🙂 | 15:07 | ||
librasteve | there is some kind of 3 way integer mod routine, please can someone remind me of the name? | 15:17 | |
lizmat | 3 way ? | 15:34 | |
librasteve | yeah I recall seeing an example that went something like 86400.threewaymod(24,60,60) | 15:37 | |
lizmat | polymod ? | 15:38 | |
docs.raku.org/type/Int#method_polymod | |||
librasteve | yep | ||
you are a genius! | |||
lizmat | It's actually N-way :-) | 15:39 | |
librasteve | yeah, so polymod has the documented signature: method polymod(Int:D: +@mods) | 15:43 | |
m: say ⅔.polymod(⅓); | |||
Raku eval | (0 2) | ||
librasteve | so that Int:D is neither doing a type check, nor a coercion ;-) | 15:44 | |
lizmat | i think that's a doc issue | 15:45 | |
librasteve | I think the examples are great and what polymod should dwim ... but maybe I should go for a doc issue (do you agree?) | ||
lizmat | yes | ||
librasteve | snap | ||
back on vanilla mod, then something is definitely broken... I found this | |||
m: say 10 mod 3.4 | 15:46 | ||
Raku eval | Exit code: 1 Cannot resolve caller infix:<div>(Int:D, Rat:D); none of these signatures matches: (Int:D $a, Int:D $b --> Int:D) (int $a, int $b --> int) (uint $a, uint $b --> uint) in block <unit> at main.raku line 1 | ||
librasteve | m: say (10 mod 3.4) | ||
Raku eval | Exit code: 1 Cannot resolve caller infix:<div>(Int:D, Rat:D); none of these signatures matches: (Int:D $a, Int:D $b --> Int:D) (int $a, int $b --> int) (uint $a, uint $b --> uint) in block <unit> at main.raku line 1 | ||
librasteve | hmm in the repl I get [27] > 10 mod 3.4 -0.2 | ||
github.com/Raku/doc/issues/4446 | 15:51 | ||
lizmat | librasteve++ | ||
librasteve | ^^^ that's polymod "sorted" | ||
16:16
avuserow left
16:17
avuserow joined
16:40
dakkar left
|
|||
nhail | Thanks for the response. There is a bit of XY problem going on on my end, I'm trying to make use of the StrDistance feature in Raku to calculate Levenshtein distance. The working method for me is StrDistance.new(before=>'new',after=>'old'), but this is kind of long, and I was looking for a way to do it with tr/// instead. | 19:07 | |
19:22
vlad left
|