🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). 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 6 September 2022.
tbrowder__ that checks, thanks. i think this will do what i need. 01:26
lizmat . 09:15
patrickb guifa: Can you do a release of DateTime::Timezones? Latest version in uninstallable without manually preinstalling its deps. 11:53
tonyo . 15:33
tbrowder__ hi, i need help with hyper on a hash. the hash k 16:42
*looks like this: %h = a => [1, 2, 3, 4], b=> [2, 3, 4, ]; 16:44
i need to multiply all values by the same value, say $a = 3 16:45
i can do it on an array fine 16:46
m: my @a = 1, 2; my @b = @a >>*>> 2 16:47
camelia ( no output )
tbrowder__ m: my @a = 1, 2; my @b = @a >>*>> 2; say @b.raku 16:48
camelia [2, 4]
ugexe m: my %h = a => [1, 2, 3, 4], b=> [2, 3, 4, ]; say %h>>.map({$_ * 2}) 16:49
camelia {a => (2 4 6 8), b => (4 6 8)}
ugexe m: my %h = a => [1, 2, 3, 4], b=> [2, 3, 4, ]; say %h>>.map(* * 2)
camelia {a => (2 4 6 8), b => (4 6 8)}
tbrowder__ ugexe: thank you!
i guess i use the first form if the number of elements is not known? 16:53
m: my $mul = 3; my %a = a=>[1,2], b=>[2,3,6], c=> [1,2]; say %a>>.map({$_ * $mul}); 16:58
camelia {a => (3 6), b => (6 9 18), c => (3 6)}
ugexe both of the forms i posted are the same, one is just slightly shorter
tbrowder__ ok, thanks a lot! 16:59
[Coke] the {$_} version is a code block with the default argument, the * version is a Whatercode that generates a Callable (I think) - end result is the same, I find that the * version is much prettier, but the {$_} lets you do some more complicated logic sometimes if you need it. 17:01
but it's personal preference.
tbrowder__ [Coke] got it, thnx. can you give a short demo of a more complicated use? 19:11
i guess it could probably be for something that varies the action depending on the value, such as making all values even... 19:14
tonyo tbrowder__: the most common `use {$_} over *` that i've experienced would be if you need the value more than once 20:10
m: (1..5).map({$_ * $_}); (1..5).map(* * *); # doesn't work 20:11
camelia Too few positionals passed; expected 2 arguments but got 1
in block <unit> at <tmp> line 1
tonyo m: say (1..5).map({$_ * $_}); # works
camelia (1 4 9 16 25)
tonyo m: (1..5).map(* * *); # doesn't work
camelia Too few positionals passed; expected 2 arguments but got 1
in block <unit> at <tmp> line 1
[Coke] Yup, good example. 20:23
I would also feel comfortable making the {} version cover multiple lines, whereas I think that'd be awkward with the * version 20:24
(again, that's preference. I'd probably write an explicit sub and use that if it was *that* long.
Nemokosch m: (1..6).map(* * *).say 20:39
Raku eval (2 12 30)
Nemokosch it "works", for { $^a * $^b } 20:40
tonyo that example demonstrates how awkward it can be, also 21:53
Voldenet .map(* * *) is rapidly collapsing into being useless, I'm hardly ever using non-unary form 22:14
it only works well for things like .sort 22:15
if `.map(*1 * *1)` or something similar existed, it would reduce the pain of referencing and reordering arguments 22:16
lizmat .map( -> $a, $b, $c { ... } ) ?? 22:23
Nemokosch m: 1, 1, * + * ... * andthen .[^10].say 22:26
Raku eval (1 1 2 3 5 8 13 21 34 55)
Nemokosch the classic
Voldenet `.map({ $^a * $^a })` exists but those { } are so horrible to type in 22:29
guifa patrickb: that's weird, what's the dep that it doesn't like? 22:32
gfldex Voldenet: You can define input shortcuts that type ({}) and move the cursor right to the right spot. I do that with „“, looks like this in my digraph file: '""' => '„“D', 22:34
That's a ^D in there.
Voldenet I know, but input tools for editing source code are poor solution to the problem 22:35
especially when amount of ({ }) starts to obfuscate the problem 22:37
gfldex I like to use @a».&{ $^a * $^b } . 22:40
Xliff \o
tellable6 2023-04-30T23:55:36Z #raku <tbrowder__> Xliff see cpan Astro::MoonPhase; that's the source (last update 2007), then manipulated it to my needs into a json format
Xliff If I have this in Perl5: "use DBI::Log file => "~/querylog.sql";" -- How would I invoke this in Raku for Inline::Perl5?
Voldenet perhaps `use DBI::Log:from<Perl5> file => "~/querylog.sql"` would work 22:44
Xliff .tell tbrowder LOL! thanks for the pointer. I might use it. This comes after I had already written a NativeCall based module for Raku! Maybe you could help me with the release? Email: [email@hidden.address] 22:45
.tell tbrowder LOL! thanks for the pointer. I might use it. This comes after I had already written a NativeCall based module for Raku! Maybe you could help me with the release? Email: clifton.wood@gmail.com
tellable6 Xliff, I'll pass your message to tbrowder__
Xliff What about "use DBI::Log trace => 1file => "~/querylog.sql";"
Actually... 22:46
use DBI::Log trace => 1 file => "~/querylog.sql";
Aaand... no dice -- Error while importing from 'DBI::Log': no such tag 'trace' 22:47
Voldenet it appears to me that hashes should be made references automatically in the context of use as well
maybe this: use DBI::Log:from<Perl5> { :trace(1) :file("~/querylog.sql") }
Xliff Odd... same deal 22:48
Voldenet probably :trace gets attached to `use` instead of being used as hash 22:49
Xliff This one didn't spawn errors, but that was a golf...
 raku -e 'use Inline::Perl5; use DBI::Log:from<Perl5> qw<:trace, :file("a")>'
I'll have to test that one in the app. Thanks.
Voldenet you could also do `my $p5 = Inline::Perl5.new; $p5.use('DBI::Log', { whatever hash });` 22:53
I'm not sure if that would work 22:54
Xliff The one that actually did... 23:00
raku -e 'use Inline::Perl5; use DBI::Log:from<Perl5> <:trace, :file("a")>'
Thanks for your help, Voldenet++ 23:01
guifa patrickb: I just did a `zef uninstall DateTime::Timezones` and `zef uninstall Timezones::ZoneInfo` and then `zef install DateTime::Timezones` and it worked without problem. Can you send me the error message you're getting? 23:07