Stéphane writes:
 
   > Hyper operators with operands of different size are partly covered
   > in A3:
   > 
   >   Hyper operators will also intuit where a dimension is missing from one
   >   of its arguments, and replicate a scalar value to a list value in that
   >   dimension.  That means you can say:
   >       @a ^+ 1
   > 
   > The former example a particular case of the size an operand being a
   > multiple of the other:
   > 
   >   my @a = 6; # <= still supported in perl 6?

This assigns the single element 6 to @a. Yes, it's still supported.

But perhaps you were intending:

        my @a; $#a = 5;

which, in Perl 6, would be:

        my @a is dim(6);
        

   >   @a ^= ( 1, 2, 3);
   > 
   > could be equivalent to
   > 
   >   my @a = ( 1, 2, 3, 1, 2, 3)

But not necessarily. Could also be equivalent to:

   >   @a = ( 1, 2, 3, @a[3], @a[4], @a[5])

See below.


   > We could even extend to operands where none size is a multiple of the
   > other but I can't see any reason to do that. Also I can't see what
   > happens when we deal with multidimension arrays. I don't know/remember
   > if perl6 will make the distinction between jagged multidimensional
   > arrays (à la C and perl5) and rectangular ones
   > 
   > So my question is: where do we stop? What happen if we can't carry
   > an hyperator?

Hyperoperators will raise their lower-dimensioned operand to the
dimension of their higher-dimensioned operand, by replicating the
lower-dimensional operand "perpendicularly to itself" (as it were).

So:

        (1,2,3) ^+ 1

becomes:

        (1,2,3) ^+ (1,1,1)

and:

        ([1,2],[3,4]) ^+ (1,2)

becomes:

        ([1,2],[3,4]) ^+ ([1,2],[1,2])

etc.

To deal with length mismatches within the same dimension, hyperoperators
will pad values (usually the operation's identity value) as necessary.

So:

        (1,2,3,4) ^+ (5,6)

becomes:

        (1,2,3,4) ^+ (5,6,0,0)

whilst:

        (1,2,3,4) ^* (5,6)

becomes:

        (1,2,3,4) ^* (5,6,1,1)


Padding with the identity value is why the earlier assignment example
was padded with @a's existing elements.


   > Really hyper-operator is too long :)
   > How do you say "mot valise" in English to denote this conflation of words,
   > I think Lewis Caroll had a word for that.

As Dan suggested, "portmanteau word" is the English equivalent.

Though "hyper-operator" is not -- technically -- such a thing. It's
merely a prefixed word. We *could* coin the portmanteau word "hoperators"
though, if you'd prefer. Verry hupper-clawss, owd bean!

;-)

Damian

Reply via email to