01:17 parv left 04:40 Flwyd joined
Flwyd What's the usual way to split a program across multiple files? E.g. foo.raku has `class Foo` and bar.raku has `class Bar` and the two classes can reference each other? 04:45
I've read the documentation on modules, packages, and compunits, and I don't _think_ I want to make a module for each class. 04:46
04:50 Kaiepi joined 05:26 sjn left, Flwyd left, qorg11 left, sivoais left, mjgardner left, tbrowder left, SmokeMachine left, hexology left, Util_ left, codesections left, CIAvash left, samebchase left 05:27 Flwyd joined, sivoais joined, qorg11 joined, hexology joined, sjn joined, Util_ joined, mjgardner joined, tbrowder joined, SmokeMachine joined, CIAvash joined, samebchase joined, codesections joined 05:50 samebchase left 08:04 riffraff joined
SmokeMachine Flwyd: usually you have 1 .raku file that can “import” other .rakumod files using `use` (docs.raku.org/language/modules#index-entry-use) 08:48
Flwyd: an example using 3 different files: glot.io/snippets/g4wdiwvfta 08:54
09:01 frost joined, frost left 09:13 dakkar joined 11:01 riffraff left 11:02 riffraff joined 11:11 riffraff left, riffraff joined 11:15 riffraff left 11:40 riffraff joined
Nemokosch is there a short way to transpose a two-dimensional array? 13:18
atroxaper Yes. andrewshitov.com/2019/09/09/how-to...in-perl-6/ 13:29
Nemokosch zip reduce 🤯 13:30
very clever, thank you
hm, wait 14:22
why does this work?
m: dd [1, 2] Z [3, 4] Z [5, 6]; 14:23
m: dd ([1, 2] Z [3, 4]) Z [5, 6]; 14:24
> sub infix:<Z>(**@lists --> Seq:D) is assoc<list> 14:25
is this because of the list associativity?
Hydrazer how can i fix string keys in hash? ```pl 14:32
my %hash{Int} = (3 => 5, 5 => 1, 6 => 4);
%hash = %hash.Hash.kv.map(-> $a, $b {$b => $a}).Hash;
say %hash
``````
Type check failed in binding to parameter 'key'; expected Int but got Str ("5")
in block <unit> at file0.code line 2
```
hm seems to work if i declare a new hash then insert into that one 14:36
14:44 A26F64 joined
atroxaper => Operator makes left side be Str. = operator takes (in first line) takes a list from the right side (yes, it is list) and `convert` it to hash. But in second line you already have a hash on the right side and = operator do not convert it. If you change `.Hash` to `.List` in second line, it will work. 14:46
Change the trailing .Hash, of course. 14:48
Hydrazer can you check my gist in <#783746907225980958> im not sure why half the time it say ``` 14:50
Cannot look up attributes in a VMNull type object
in block <unit> at 2021/06/part_two.raku line 40
```
tried for an hour but i can't get consistent result 14:52
atroxaper What should I pass to 'get' ? 14:57
15:00 riffraff left, riffraff joined 15:21 riffraff left, riffraff joined 15:25 riffraff left
Nemokosch can I use the hyper operator to perform multiple operations on the same data? 15:29
atroxaper `(1,22,333,4444)>>.Str>>.chars` ? 15:31
Nemokosch oh, I didn't phrase it clear enough 15:33
I'd like to get some f1(v), f2(v), f3(v)
to further complicate things, v is supposed to be a positional 15:34
Xueji Today I have learned, that raku has a class for signature (of callable) - which is interesting. I don’t think I have everseen language treating a signature like an object. 15:49
Why is that? Did any of you used class signature for something cool?
Today I have learned, that raku has a class for signature (of callable) - which is interesting. I don’t think I have everseen language treating a signature like an object. 15:50
Why is that? Did any of you used class Signature for something cool?
atroxaper @Nemokosch#9980 I invent something like: 15:52
```
my sub f1(@v) { @v>>.Str.List }
my sub f2(@v) { @v>>.Int.List }
multi sub infix:<@>(Block $f, \v) { $f(v) }
say (&f1, &f2) >>@>> ([1,2,3],)
```
But I fail somewhere -> runtime error. Probably you will fix it. Or do some better solution.
Nemokosch thanks anyway 15:55
15:55 riffraff joined
ionsolo ```perl 15:58
(^100)>>.&(-> \v {(v * 2), (v*4), (v*7) })
```
atroxaper @Xueji#0156 15:59
```
sub foo($foo, :$bar!) { say "$foo, $bar" }
my @good = 1, bar => 2;
my @bad = foo => 1, bar => 2;
say |@good ~~ &foo.signature; # True
say |@bad ~~ &foo.signature; # False
```
We get arguments and check if they satisfy the signature. In other words, can we pass them to the function.
@ionsolo#0792 brilliant!🤩 16:00
Nemokosch i mean... 16:02
this is basically one call, isn't it?
not so different from calling map
ionsolo lol yes, you have and example of structure of output you want? 16:03
for example f1(v) changes something in place or not? 16:04
Nemokosch no
very blantly put, I want to pass .min, .max and possibly other similar method calls to some positional
And I'm not even sure whether the hyper metaoperator supports any syntax for calling multiple methods for the same object in a parallel fashion 16:06
lakmatiol python has this too, it is often used for creating nice APIs, e.g.. fastAPI infers the parameters for an endpoint from it. Not sure anyone tried that in raku specifically though. 16:09
ionsolo ohh let me see 16:13
```perl
my @results = .min,.max,.other with @data
```
it's something like this? 16:15
Nemokosch yes
ionsolo I think I'm missing something in the translation 😔
Nemokosch hm?
ionsolo what is hm? 16:17
Nemokosch what did you mean? 16:18
ionsolo I don't known what is hm, I search on Google and I get cloth stuff 16:19
Nemokosch are you trolling or something? 😆 16:20
ionsolo ohh, I mean I am not a English native speaker
loool
Xueji Aha, I see. I usually work with statically typed languages, they usually don’t have that. I will check python examples, thanks! 16:21
Nemokosch this is a way to do it without hyper operator and I wonder whether this can be rephrased using it 16:25
atroxaper Am I right, that you can introspect a function signature in python, but you do not have a signature as object (and attribute of a function) as we have in Raku?
lakmatiol there is a Signature type 16:26
but it is indeed not an attribute of a function
the `inspect` module constructs it by inspecting other function attributes
atroxaper Something similar, yes. 16:27
I think, Python's situation is like in Java. You can 'create signature object' by introspection. 16:31
16:33 A26F64 left 16:39 riffraff left, riffraff joined 17:08 azee joined 17:09 azee left
ionsolo I think even is possible do it in parallel 17:29
17:30 riffraff left, riffraff joined 17:35 dakkar left
Nemokosch I don't understand it 17:42
17:44 discord-raku-bot left 17:45 discord-raku-bot joined 17:58 Flwyd left
ionsolo another way could be 19:08
```perl
(&min,&max)>>.&{$_(@data)}
```
Nemokosch does this really work? It looks okay 19:10
ionsolo i refer before: should be a way to do (call many functions) on a @array reading in once for all function, I mean reading @array once and get the results for all functions, should be a way without do loops but I don't known how 19:14
the other day found this and I think some ideas could be translated to alter the way of coding in raku 19:16
www.jsoftware.com/help/jforc/loopl...have_r.htm
but also I'm lazy
19:22 melezhik joined
gfldex I did use signature introspection a few times. One of them can be found here: gfldex.wordpress.com/2019/01/23/a-picky-caller/ 19:43
20:03 riffraff left 20:04 riffraff joined 20:05 riffraff left, riffraff joined 20:06 melezhik left
lizmat and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2021/12/06/2021-...ing-is-on/ 20:41
20:43 melezhik joined 21:10 melezhik left 22:19 tbrowder left 22:21 riffraff left, riffraff joined 22:22 tbrowder joined 22:27 riffraff left
Hydrazer is there a better way to set a default value in a hash map if it doesn't exist? ```pl 22:33
my %hash;
my $num = 3;
if !%hash{$num}:exists {
%hash{$num} = "chicken";
}
%hash{$num} ~= "bruh";
dd %hash;
``````
Hash %hash = {"3" => "chickenbruh"}
```
22:33 pamplemousse joined
is there a better way to set a default value in a hash map if it doesn't exist? ```pl 22:34
my %hash{Int:D} of Str:D;
my $num = 3;
if !%hash{$num}:exists {
%hash{$num} = "chicken";
}
%hash{$num} ~= "bruh";
dd %hash;
``````
Hash[Str:D,Int:D] %hash = (my Str:D %{Int:D} = 3 => "chickenbruh")
```
is there a better way to set a default value in a hash map if it doesn't exist and then immediately do something with it? ```pl
my %hash{Int:D} of Str:D;
my $num = 3;
if !%hash{$num}:exists {
%hash{$num} = "chicken";
}
%hash{$num} ~= "bruh";
dd %hash; 22:35
``````
Hash[Str:D,Int:D] %hash = (my Str:D %{Int:D} = 3 => "chickenbruh")
```
is there a better way to set a default value in a hash map if it doesn't exist and then immediately do something with it? ```pl 22:36
my %hash{Int:D} of Str:D;
dd %hash;
my $num = 3;
for ^5 {
if %hash{$num}:!exists {
%hash{$num} = "chicken";
}
%hash{$num} ~= "bruh";
}
dd %hash;
``````
Nemokosch I feel like we are stuck with the same questions 22:43
a missing value yields Nil, right? 22:44
```perl 22:47
my %hash{Int:D} of Str:D;
dd %hash;
my $num = 3;
for ^5 {
%hash{$num} //= "chicken";
%hash{$num} ~= "bruh";
}
dd %hash;
```
Morfent m:``` 22:51
my %hash{Int:D} of Str:D is default<chicken>;
dd %hash;
my $num = 3;
%hash{$num} ~= 'bruh' for ^5;
dd %hash;
```
22:52 riffraff joined 22:58 pamplemousse left 23:00 riffraff left 23:13 riffraff joined
Nemokosch is default seems cool 23:13
what do we have for partial application of functions?
23:19 riffraff left
gfldex @Nemokosch#9980 docs.raku.org/routine/assuming and docs.raku.org/routine/o,%20infix%20%E2%88%98 23:30
if i got you right ...
Nemokosch Probably it will be useful, no matter what 😄
A higher-priority question showed up
can I turn a list of two values into a range?
i.e the opposite of Range.bounds()
23:32 riffraff joined
lakmatiol ``` 23:32
Range.new(|(1,5))
1..5
```?
Nemokosch oh lol, this was unexpectedly simple 😅 thanks 23:33
23:41 riffraff left
Hydrazer neat 23:42