🦋 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.
moon-child m: say sprintf "%03s", 1.2 01:24
camelia 1.2
moon-child I want three integer digits ahead of the decimal point, regardless of what's after it. Is there a simple way of doing that? 01:25
gfldex m: say sprintf "%0fs", 1.2 01:26
camelia 1.200000s
moon-child (that is, 001.2)
gfldex m: say sprintf "%0.3f", 1.2 01:27
camelia 1.200
gfldex m: say sprintf "%3.3f", 1.2
camelia 1.200
gfldex m: say sprintf "%03f", 1.2
camelia 1.200000
gfldex m: say sprintf "%03s", 1.2 01:28
camelia 1.2
gfldex m: say sprintf "% 3s", 1.2
camelia 1.2
moon-child m: say sprintf "%03.f", 1.2
camelia 001
moon-child cool would be if you could say
gfldex m: sprintf("%03f", 1.2).say
camelia 1.200000
moon-child m: say sprintf "%03.*f", Inf, 1.2
camelia Directive %f not applicable for value of type Rat (Inf) in format
'%03.*f'
in block <unit> at <tmp> line 1
ggoebel m: printf "%1\$03d\b%0.2f", 1.2; 03:39
camelia 0011.20
ggoebel m: printf "%1\$03d\b\b%0.2f", 1.2;
camelia 0011.20
ggoebel the first works from the command line... 03:40
i.e. gives 001.20 03:41
moon-child ggoebel: first: that gives the wrong result for e.g. 11.2; second: I don't want something that displays like 001.2, I want the actual string 001.2
ggoebel can't figure out a clean way to get zero padding before floating point numbers 03:42
moon-child it's fine, I can build it myself; was just curious if there was a good feature built-in
ggoebel locally it prints 001.20
somethings up with whatever m: does... guessing it doesn't handle \b
moon-child the reason it displays that way is because of your terminal 03:43
and, for irc, your irc client
what I want is to generate filenames that will be ordered correctly when sorted lexicographically. So embedded backspaces do not help
ggoebel m: my $a = sprintf "%1\$03d\b%0.1f\n", 1.2; $a.say 03:44
camelia 0011.2
ggoebel guess you'll have to roll it yourself 03:45
m: 1.2 ~~ /(\d+)\.(\d+)/; my $a = sprintf "%03d.%d", $/[0,1]; $a.say; $a.chars.say; 03:53
camelia 001.2
5
mcmillhj Is there a way to unpack a Pair in a block? Something like `for @pairs -> $k, $v { ... }` ? 04:30
I am sure there _is_ a way, I just can't seem to get the syntax right
moon-child hmm, ideally you would be able to say for @pairs -> ($k => $v) { ... }, but that does not seem to work 04:33
mcmillhj that was sort of what I expected to work too 04:34
moon-child could say for @pairs.map(&kv) -> $k,$v { ... }
mcmillhj okay, I'll try that. Thank you 04:43
Geth ecosystem: JRaspass++ created pull request #598:
Fix Math::Root's branch
10:06
Geth ecosystem: b805cd2663 | (James Raspass)++ (committed using GitHub Web editor) | META.list
Fix Math::Root's branch

Math::Root uses `main` rather than `master`, the fact that master works is just GitHub trying to be helpful. Unfortunately this helpfulness doesn't extend to their GraphQL API.
This change fixes gitlab.com/raku-land/raku-land/-/issues/18
10:15
ecosystem: 294d846bee | (Juan Julián Merelo Guervós)++ (committed using GitHub Web editor) | META.list
Merge pull request #598 from JRaspass/patch-2

Fix Math::Root's branch
JRaspass heh when IRC tells you before email that your PR was merged :-P
ggoebel m: my @pairs = :a(0), :b(1); for @pairs>>.kv.flat ->$k,$v { say "k: $k, v: $v" } 10:19
camelia k: a, v: 0
k: b, v: 1
SmokeMachine m: my @pairs = :a(0), :b(1); for @pairs ->(:$key,:$value) { say "k: $key, v: $value" } 10:57
camelia k: a, v: 0
k: b, v: 1
SmokeMachine .tell mcmillhj m: my @pairs = :a(0), :b(1); for @pairs ->(:$key,:$value) { say "k: $key, v: $value" } 10:59
tellable6 SmokeMachine, I'll pass your message to mcmillhj
SmokeMachine m: my @pairs = :a(0), :b(1); for @pairs -> (:$key,:$value) { say "k: $key, v: $value" }
camelia k: a, v: 0
k: b, v: 1
lizmat clickbaits rakudoweekly.blog/2021/12/13/2021-...or-micros/ 11:44
thundergnat m: printf "%03d.%s\n", .Int, ($_ - .Int).substr(2) for 1.1443, 17.12313122, e, pi; 12:46
camelia 001.1443
017.12313122
002.7182818284590451
003.14159265358979312
thundergnat moon-child ^^^^ maybe something like this? 12:47
still would be a problem for negative numbers but could probably trap that pretty easily. 12:48
m: printf "%s%03d.%s\n", .sign < 1 ?? "-" !! "", .abs.Int, (.abs - .abs.Int).substr(2)//0 for 2, 5.1, 1.1443, 17.12313122, e, pi, -3.98 12:55
camelia 002.0
005.1
001.1443
017.12313122
002.7182818284590451
003.14159265358979312
-003.98
thundergnat or, maybe better for integers... 12:57
m: printf "%s%03d%s\n", .sign < 1 ?? "-" !! "", .abs.Int, (.abs - .abs.Int).substr(1)//"" for 2, 5.1, 1.1443, 17.12313122, e, pi, -3.98
camelia 002
005.1
001.1443
017.12313122
002.7182818284590451
003.14159265358979312
-003.98
ggoebel SmokeMachine: very nice. didn't know you could do that 14:16
why doesn't this work?
m: my @pairs = :a(0), :b(1); for @pairs ->(:$k,:$v) { say "k: $k, v: $v" }
camelia 2 unexpected named arguments passed (value,key) in sub-signature
in block <unit> at <tmp> line 1
ggoebel guessing I'm not understanding what is going on
timo the attributes are called key and value, not k and v 14:23
ggoebel how does one introspect what attributes are present? 14:25
lizmat m: my @pairs = :a(0), :b(1); for @pairs ->(:key($k),:value($v)) { say "k: $k, v: $v" }
camelia k: a, v: 0
k: b, v: 1
lizmat m: .say for Date.^attributes 14:26
camelia int $!year
int $!month
int $!day
int $!daycount
Callable &!formatter
lizmat m: class A { has $.foo = 42 }; if A.new -> (:foo($bar)) { dd $bar } 14:28
camelia 42
ggoebel m: my @pairs = :a(0); for @pairs { .^attributes.say }
camelia (Mu $!key Mu $!value ObjAt $!WHICH)
ggoebel thank you 14:29
Anton Antonov I made a package that downloads data over the web from some well known resources site (say, a GitHub repository.) I want to provide option for the data to be kept in the local machine. Can I use, say, the resources directory for that? I programmed a solution that does that, but I am sure it is way too hacky and ideologically wrong. Are there any documents discussing these kind of topics? (I searched for 14:32
merryprog Anton, you got cut off at "I searched for" 14:33
Anton Antonov 🙂 " (I searched for ~15 min and did not find any.)" 14:34
timo check out tha xdg spec maybe 14:37
Anton Antonov timo, Thanks! 14:52
SmokeMachine m: class Bla { has $.something; has $.else }; for (Bla.new: :something($_), :else($_ * 2) for ^5) -> (:something($a), :else($b)) { say "a: $a; b: $b"} # ggoebel, not only for Pairs 15:20
camelia a: 0; b: 0
a: 1; b: 2
a: 2; b: 4
a: 3; b: 6
a: 4; b: 8
SmokeMachine it seems to be using the method to get the value: 15:29
m: class Bla { has $.a = 13; method a { 42 } }; for Bla.new xx 5 -> (:$a) { say "a: $a"}
camelia a: 42
a: 42
a: 42
a: 42
a: 42
Anton Antonov @timo Thanks again! Worked great. 15:30
timo cool!
SmokeMachine but testing if the attribute is public:
class Bla { has $!a = 13; method a { 42 } }; for Bla.new xx 5 -> (:$a) { say "a: $a"}
evalable6 Use of uninitialized value element of type Mu i…
SmokeMachine, Full output: gist.github.com/8711594aa7852d75e1...0233341509
timo the resources folder is really only for stuff you, as a module author, want to install on the user's system
SmokeMachine that seems odd to me...
timo it goes via method Capture 15:41
class Bla { has $!a = 13; method a { 42 } }; say Bla.new.Capture; class Bloop { has $.a = 13; method a { 99 } }; say Bloop.new.Capture
evalable6 \()
\(:a(99))
SmokeMachine timo: ok... for some reason now that makes more sense in my mind... 15:48
timo: thanks
m: 42.Capture 15:49
camelia Cannot unpack or Capture `42`.
To create a Capture, add parentheses: \(...)
If unpacking in a signature, perhaps you needlessly used parentheses? -> ($x) {} vs. -> $x {}
or missed `:` in signature unpacking? -> &c:(Int) {}
in block <unit> at…
SmokeMachine m: say 42.Capture
camelia Cannot unpack or Capture `42`.
To create a Capture, add parentheses: \(...)
If unpacking in a signature, perhaps you needlessly used parentheses? -> ($x) {} vs. -> $x {}
or missed `:` in signature unpacking? -> &c:(Int) {}
in block <unit> at…
Geth doc/codesections-isa-ok-roles: f14286b4ff | (Daniel Sockwell)++ (committed using GitHub Web editor) | doc/Type/Test.pod6
State that isa-ok matches Roles

Mu.isa explicitly does *not* match roles, so it seems worth calling out that &isa-ok behaves differently.
16:25
doc: codesections++ created pull request #3997:
State that isa-ok matches Roles
16:26
Geth doc: 894ab10ecb | (Daniel Sockwell)++ (committed using GitHub Web editor) | doc/Type/Test.pod6
State that isa-ok matches Roles (#3997)

Mu.isa explicitly does *not* match roles, so it seems worth calling out that &isa-ok behaves differently.
18:59
linkable6 Link: docs.raku.org/type/Test
[Coke] . 19:23
jdv codesections: around? 19:30