Posts

Showing posts with the label infix-notation

Implementation of a function object “power” operator in Raku

20 2 In APL there is the power operator ⍣ , which if applied to a function f superimposes the application of f . How to implement that operator in Raku? For example, with this definition of f : sub f(Int:D $i){ $i + 1 } the command say (f ⍣ 4)(10); should be equivalent to say f(f(f(f(10)))); . My implementation below is for a function with one argument. Questions How one should extend or replace it with a better implementation that works on multiple (or any) signatures? How to define "high precedence" of that new power operator? Is there are better way to define the "identity function" result for f ⍣ 0 ? Reference links Here is a description of APL's ⍣ : "Power Operator". ( ⍣ is a "star with two dots", or mo...