🦋 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 inspection is getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 25 August 2021.
thowe I always use rakudobrew, is that not what the cool kids do anymore? 01:07
ugexe the cool kids use rakubrew 01:24
moon-child what are those? 01:25
moon-child just builds from source
Geth doc: 81ddc2686b | Coke++ | xt/examples-compilation.t
Fix heuristic

previous version tripped over 'subset', mistaking it for a sub.
Add 'submethod'
03:02
doc: b6bccb6d43 | Coke++ | doc/Language/typesystem.pod6
Fix example compilation

These need to be separate blocks since they're redefining the same thing.
They also need a preamble because they are using A & B
linkable6 Link: docs.raku.org/language/typesystem
doc: 1f3f3e4fd4 | Coke++ | 7 files
Pass xt/examples-compilation
kybr is there a method for getting the fractional part of a number? 06:46
raydiak I use mod 1. idk if there's a more specialized method 06:50
m: say 2.3 % 1
camelia 0.3
kybr modules.raku.org/dist/Math::FractionalPart 06:51
thanks. i think i will use mod 1 06:52
raydiak yw
moon-child can also do - truncate if you wanna preserve sign 06:57
m: say -2.3 % 1; say -2.3 - truncate -2.3
camelia 0.7
-0.3
moon-child oh--that doesn't just not preserve sign, it mangles it completely. Subtract floor if you wanna discard sign
err 06:58
spacekookie howdy! I'm trying to write a raku program that uses a multi sub MAIN to distinguish between different usages. But for some reason only one of my functions is ever called (and prints the help text if I don't provide the needed parameters) dev.spacekookie.de/kookie/nomicon/.../pt-import 09:06
lizmat lose the "--" on the "--version" 09:15
that is, if you want it to work like "foo version"
rather than: "foo --version"
if the latter, change the signature to: :$version! 09:16
aka, a required named parameter "version"
spacekookie ^^
spacekookie Hmm 09:17
That's kinda annoying because neither of them are a standard way of asking for the version of a program x) 09:20
lizmat so what is the standard way of asking the version of a program in your opinion?
spacekookie This is especially weird to me because if I change my functions to be "multi sub f" and then call f(|@*ARGS) then it works
foo --version
lizmat then the signature should be :$version! 09:21
which will make it call that candidate with --version
spacekookie Hmm, yea I guess that works 09:22
Aah yea okay and if I then constrain the type to Bool then I get rid of the ugly --version[=Any] tail in the usage
Thanks!
lizmat yup :-) 09:23
spacekookie coolio :P
spacekookie Different question but is there a way to get an index for each element in a list? In RustI would call .enumerate() on the iterator (or .zip(0..)) but looking at the List docs I can't relaly find a function that does something equivalent 10:14
raydiak idk rust, but if I understand correctly you're looking for .antipairs 10:57
that'll give you a list of pairs. it can be assigned to a hash as normal, or you can call .hash explicitly if needed 10:59
lizmat m: my @a =<a b c"; say @a.keys # spacekookie 11:36
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in quote words; couldn't find final '>' (corresponding starter was at line 1)
at <tmp>:1
------> 3a =<a b c"; say @a.keys # spacekookie7⏏5<EOL>
expecting an…
lizmat m: my @a =<a b c>; say @a.keys # spacekookie
camelia (0 1 2)
raydiak .antipairs is still my final answer but just for reference after a bit of reading, rust's .enumerate would be something along the lines of .pairs.map or .kv.map in raku, and our .zip is the Z operator: `@list Z 0..*` (or the less common synonymous zip function: `zip @list, 0..*`) 12:30
elcaro weekly: www.youtube.com/watch?v=UVUjnzpQKUo 14:26
notable6 elcaro, Noted! (weekly)
gfldex elcaro: I could not resist the urge to comment on that video. :-> 15:05
Nemokosch omg what a dumb video 16:56
kybr what are NuT and DeT types? 18:06
> No such method 'gist' for invocant of type 'NuT' 18:09
> Type check failed in binding to parameter '<anon>'; expected Any but got DeT (DeT)
gfldex kybr: those are not buildins 18:10
kybr i have not yet made a minimal example to test, but the NuT/DeT types made me curious, so i'm asking about those.
ugexe where are you reading about Nut and DeT types? 18:11
kybr not; cant find anything so far.
just searched the moarvm github and found nothing. 18:13
ugexe if you have never read anything on these types why do you think they are a thing? 18:14
like i dont know what those are period, let alone in the context of raku 18:15
kybr well, raku error messages mentioned these types and i didn't create them. github.com/rakudo/rakudo/search?q=NuT 18:18
gfldex kybr: if a type defines methods, you can use introspection to get holed of the Method object and call .file and .line on it.
kybr (Nu)merator(T)ype
(De)nominator(T)ype 18:19
ugexe ::NuT = Int
ugexe its a named typed capture 18:21
although i agree that would be confusing to reference in an error message 18:22
docs.raku.org/type/Signature#Type_captures 18:23
kybr my goodness raku is deep 18:25
gfldex kybr: indeed. I happen to be falling since 2008. :) 18:53
lizmat . 19:24
kybr m: my Numeric @s; @s.push: True; @s[0].say 20:06
camelia True
kybr specifying the type Numeric of an array does not mean that elements are coerced to that type?
there's probably a set of good reasons, but how might i make the coercion automatic 20:07
gfldex The constraint is on @s not the containers inside @s;
kybr aaah. 20:08
gfldex m: my Numeric @s; @s = [ True ];
camelia ( no output )
gfldex m: my Numeric @s; @s := [ True ];
camelia Type check failed in binding; expected Positional[Numeric] but got Array ([Bool::True])
in block <unit> at <tmp> line 1
kybr do i want `my Array[Numeric] @s;`? 20:09
gfldex m: my Numeric @s; @s.push: 'True'; @s[0].say 20:12
camelia Type check failed in assignment to @s; expected Numeric but got Str ("True")
in block <unit> at <tmp> line 1
gfldex kybr: The constraint will do, but Bool is Numeric.
kybr oh no. i had assumed otherwise. 20:13
m: True ~~ Numeric 20:14
camelia ( no output )
kybr m: say True ~~ Numeric
camelia True
kybr m: True.Numeric.^name.say
camelia Int
gfldex m: say 1 + True; 20:15
camelia 2