guifa tope#9134: actually, the role method won't speed things up, I just did some testing on that. I'm trying to see if I can find a way to speed it up a bit but no promises 02:57
Razetime how would i apply a function at given indices in an array? 09:53
lakmatiol ```perl 10:07
> my @a = 1,2,3,4
[1 2 3 4]
> my @idx = 1,3
[1 3]
> @a[@idx] = @a[@idx]>>.&{$_ + 9}
(11 13)
> @a
[1 11 3 13]
```
if you don't want to restate the `@idx`, you can do: 10:09
```perl
@a[@idx] .= map(* + 9)
```
SmokeMachine tope#9134: here is an example of adding a candidate to infix:<+>: github.com/FCO/Red/blob/master/lib...rs.pm6#L47 13:16
tope guifa: for now I'm not overly concerned with speed but trying to understand how it's possible / isn't possible. like with the `&infix:<+> does ROLE` solution, I don't know how to access the normal +(int,int) from inside that role(??). when I try to callsame from `+(IntSubclass, Int)` (to do a `+(Int,Int)`), `callsame` just returns undef for some reason. `callsame` from `+(IntSubclass, IntSubclass)` corre 13:20
SmokeMachine: and yeah that is what I had originally. I could add and do arithmetic fine for myself, but when I gave my special `IntSubclass` instances away for other libraries that did arithmetic (like `Math::Vector`), they were just reverted to `Int`s. 13:23
SmokeMachine m: my @a = 1,2,3,4; say @a; my @idx = 1, 3; @a[@idx] >>+=>> 9; say @a 13:24
camelia [1 2 3 4]
[1 11 3 13]
SmokeMachine tope#9134: you just need to also export your operatorā€¦ and that will be able to be usedā€¦ 13:26
tope#9134: like here (github.com/FCO/Red/blob/master/lib/Red.pm6#L40) everything someone `use`s Red, they also imports the operatorsā€¦ 13:29
guifa SmokeMachine: the issue is that exported operators are limited to the lexical scope
SmokeMachine guifa: yes, but the problem is fixed if you import the operator into the scope where you want to use it, right?! 13:31
guifa SmokeMachine that assumes that you have control over those scopes 13:32
In tope#9134's case, there's no control over what Math::Vector imports into its scopes
SmokeMachine But importing his module is a simple requirement for using his operators, isnā€™t it? 13:33
guifa Yes, it would be ā€”Ā but since tope didn't write Math::Vector, there's no simple way to inject the use statement there 13:35
SmokeMachine Or tope#9134 could even make the module export the operator AND Math::Vector, that way a user would only need to `use` that module 13:36
tope my assumption was just that Math::Vector and Math::Matrix would be able to do vector/matrix stuff irregardless of the base ring/field that the elements I gave. like if I'm calculating a dot product, I don't care if I'm working with floats, Int, int-modulo-257, even polynomials or matrices over yet another ring, so long as those elements _are rings_ (that is, they have + - * and so on with the usual laws 13:38
kind of like typeclasses in Haskell I guess
guifa SmokeMachine Even in that case, Math::Vector will still not have access to the new operator within its routines. If Math::Vector has `sub double($a) is export {Ā $a + $a }`, and I have in my code `double FancyMathClass.new()`, it won't catch my operator for FancyMathClass, it'll call .Numeric on it instead and use standard math 13:40
tope#9134, try this: role ZIntAddition { my &original = &infix:<+>.clone; multi method CALL-ME (ZInt $, ZInt $) { 'special' }; multi method CALL-ME (|c) { original |c } }; &infix:<+> does ZIntAddition; 13:49
you can use original($a, $b) to call the original, unmodified addition 13:50
tope uhh, hang on, what... if I do: 13:51
```
my $vec1 = Math::Vector($arr1);
my $vec2 = Math::Vector($arr2);
"$vec1 - $vec2 = {$vec1 - $vec2} (mod {$F.modulus}) <--- ????".say;
```
it gives me: `(50, 100, 19, 69) - (11, 121, 21, 100) = (39, -21, -2, -31) (mod 131) <--- ????`
which is wrong, it's just using regular Int arithmetic
BUT, if I manually use my own `-` first: 13:52
```
my $vec1 = Math::Vector($arr1);
my $vec2 = Math::Vector($arr2);
"wc: $vec1 - $vec2 = vs<{$vec1.coordinates Ā»-Ā« $vec2.coordinates}> (mod {$F.modulus})".say;
"$vec1 - $vec2 = {$vec1 - $vec2} (mod {$F.modulus}) <--- ????".say;
```
it produces:
```
wc: (50, 100, 19, 69) - (11, 121, 21, 100) = vs<39 110 129 100> (mod 131)
(50, 100, 19, 69) - (11, 121, 21, 100) = (39, 110, 129, 100) (mod 131) <--- ????
```
suddenly Math::Vector produces the correct result, why? no other changes in code, just inserting that line 13:53
I mean this is with the original solution of just using implementing the arithmetic on my side with `multi sub infix:<+>( ... ) { ... }` etc 13:57
I mean this is with the original solution of just implementing the arithmetic on my side with `multi sub infix:<+>( ... ) { ... }` etc
without any of the role/wrap magic
is there some kind of uhh hotloading of the operators into a cache that then gets used?
guifa tope: it's possible. We're getting into stuff beyond my paygrade, but infix:<+> and kin are listed as pure, so there's the possibility of some optimization going on that's mucking with stuff. 14:01
tope hehe, all I ever wanted was to maybe write some libraries for number theory stuff *sob*, but 3 or 4 days in and I'm close to despair. I thought this oughtn't be that hard, esp in such a highly extensible language. finite fields and modular arithmetic are after all at the very heart of most cryptography primitives, from RSA to elliptic curves to NTRU. 14:11
maybe I could post a longer writeup somewhere, giving full implementations in Python which I actually know, asking for translations or equivalences. cause I reckon I'm still lost on 90% of the stuff that might be possible 14:15
I'll try this `does ROLE` + `.clone original` idea too
Anton Antonov <@93032313142669312> The Raku matrix functionalities are not that great. Useful, but still too basic. I am interested in symbolic computations, but those are not high in my priorities list. Getting Raku to have sparse matrix algebra support is of much higher priority for me. 15:01
<@93032313142669312> If use Linux take a look at `Math::Libgsl::Matrix` and `Math::Libgsl::Vectors` : github.com/frithnanth/raku-Math-Libgsl-Matrix . 15:05
stevied Hi, I'm using zef command for first time. It just hangs when I do `zef search WWW` 16:50
I'm on a mac. Is the service down? 16:51
guifa steveid: it works for me (I'm on Monterey) 16:53
does zef work for you otherwise? (sometimes gatekeeper can be....overzealous in blocking stuff IME) 16:54
stevied i'm Big Sur
i tried --help and --version. those commands work
if I do `zef search wWW` with the typo i get `===> Found 0 results` 16:55
I installed with homebrew 16:56
`zef list` works
huh, `zef search` just started working for me now 16:57
guifa 's spell worked 16:58
stevied must have been a temporary glitch
hmm, seems very flaky. just hangs with `zef search Mac` 16:59
guifa maybe your system has gremlins lol. that one returned pretty fast for me 17:01
stevied same problem with my other machine 17:03
guifa actually I just got it to do that for me as well. I just pinged the developer of zef on the main channel to see if I can get you any more info 17:06
stevied ok, thanks. and why does it say you are a bot? I'm confused? 17:07
guifa I'm on IRC, and you're on Discord 17:12
the bot passes messages between the two
(you also show up as a bot to me hahaha)
stevied ah, very cool 17:19
I feel like I'm living in the 21st century finally. šŸ™‚ 17:20
guifa stevied: I just got a response, he said likely one of the ecosystems it searches is stalling 17:27
stevied ok, thanks. I'll just wait it out. I wasn't sure if the website docs were out of date or what. 17:28
so I'd like to get contribute a very simple module to get my feet wet with raku. is there an account I have to get to do that like with cpan? 17:29
ok, nvm, found it in the docs: docs.raku.org/language/modules#Dis...ng_modules 17:32
guifa Yes, but they can be very informal. There's CPAN and p6c that you find there. p6c is just you have a github repository and you submit a pull request adding a link to it 17:33
Also new is fez and that's probably where most modules will go down the line. See raku-advent.blog/2021/12/23/day-23...authoring/ 17:34
stevied yeah, this is basically just a toy module. I guess using pf6 would be the way to go
all it does is find and list applications on a mac
guifa Little modules like that are very useful 17:41
thowe I figured out how to type those corner brackets :) 18:04
stevied anyone have any idea why a blank line in a module would cause it to hang? seems like a bug. 19:11
I must be doing something wrong.
this is the module:
`
use v6;
unit module Mac::Applications::List;
my $x = '3';
when I try to load it, it just hangs 19:13
if I get rid of the blank like, it doesn't hang
hmmm, doesn't appear to be just a blank line that causes the problem. if there is a trailing space at the end of the line, it's breaking things. very weird. not sure what is causing things to hang. 19:21
It's really weird, if I make minor adjustments to code, the module can just hang. no idea what's going on. file encoding is set to utf-8 19:38
adding a blank line can break it
sometimes adding a blank line will get it working again. wtf? 19:40
i'm on an m1, can that make a difference?
MasterDuke does adding RAKUDO_MODULE_DEBUG=1 to the environment make a difference 19:41
oh, how recent is your rakudo?
stevied just downloaded it yesterday with homebrew 19:48
MasterDuke -v says it's 2021.12?
stevied raku -v
Welcome to Rakudo(tm) v2021.04.
Implementing the Raku(tm) programming language v6.d.
Built on MoarVM version 2021.04
MasterDuke that's a bit old. i don't use macos, but maybe the section here rakudo.org/downloads has something newer you can use? 19:50
stevied let me try on the docker image. I'll see if I can reproduce there
so I've got an older version looks like?
MasterDuke yeah, there have been some large changes/improvements since then
stevied alright, i'll give that a shot. thanks. 19:56
20:19 TempIRCLogger joined
ok, @MasterDuke, things seem to be working now 20:36
nice
there is a bug in the set-env script for macs, though
it's looking for grep in the /bin/grep directory on a mac 20:38
that doesn't exist, though
it's looking for grep at /bin/grep on a mac
which repo to I report that issue to? 20:42
ok, nvm, manage to find it 20:44
21:51 CIAvash joined 21:52 RakuIRCLogger left 22:16 CIAvash left 22:57 MasterDuke joined