On Mon, Oct 12, 2020 at 01:14:09PM -0300, Aureliano Guedes wrote:
: > This seems pretty convenient and intuitive.  At least, it is possible
: > to mimic that behavior in Raku:
: >
: >         List.^find_method('split').wrap: { $^a.map: *.split($^b) }
: >         List.^find_method('sin').wrap: *.map: *.sin;
: >
: This is like overwrite the function?
: Might be better just implement a new function, I mean, a new verb as is
: called in R.

In Raku these functions already have names, if you count metaoperators as a 
fancy
way to name anonymous functions:

    say <a,b c,d>».split(',');
    say (0, (π/2, 3 * π/2))».sin;

    ((a b) (c d))
    (0 (1 -1))

As shown by the ».sin example, unary hypers will distribute over
multi-dimensional structures for you, just as an APL or R programmer
would expect.  But that behavior is not intuitively obvious to everyone,
so the vector-processing paradigm is not the default.  (But we make it
really easy to get to when you want it, as you can see.  And arguably
the explicit presence of » or >> makes your intent clearer to the naïve
reader, who at least has something to look up or ask about if they don't
understand it.)

Larry

Reply via email to