|
It would be easy to just make `·` an alias. Then that code would work. my &infix:< · > = &infix:< × >;
(After all `×` itself is just an alias of `*` in the source for Rakudo.)If you need more control you can write it out sub infix:< · > (+@vals)
is equiv(&[×]) # uses the same precedence level etc.
is assoc<chaining> # may not be necessary given previous line
{
[×] @vals # reduction using infix operator
}
I made it chaining for the same reason `+` and `×` are chaining.--- I don't know enough about the topic to know how to properly write `∧`. It looks like it may be useful to write it using multis. # I don't know what precedence level it is supposed to be
proto infix:< ∧ > (|) is tighter(&[×]) {*}
multi infix:< ∧ > (
Numeric $l,
Numeric $r,
) {
$l × $r
}
multi infix:< ∧ > (
Vector $l, # need to define this somewhere, or use List/Array
Vector $r,
) {
…
}
If it was as simple as just a normal cross product, that would have been easy. [[1,2,3],[4,5,6]] »×« [[10,20,30],[40,50,60]]
# [[10,40,90],[160,250,360]]
# generate a synthetic `»×«` operator, and give it an alias
my &infix:< ∧ > = &infix:< »×« >;
[[1,2,3],[4,5,6]] ∧ [[10,20,30],[40,50,60]]
# [[10,40,90],[160,250,360]]
Of course, I'm fairly confident that is wrong. |