develooper Front page | perl.perl6.language | Postings from October 2001

Re: reduce via ^

Thread Previous | Thread Next
From:
Damian Conway
Date:
October 10, 2001 16:55
Subject:
Re: reduce via ^
Message ID:
200110102355.JAA10025@indy05.csse.monash.edu.au


   > So, does that mean:
   > 
   > $a = ($a) ^+ @b;
   > print $a; # prints: 3
   > # $a = ($a,undef,undef) ^+ @b  ...

Yes.

   > My new confusion has to do with why does the hyperoperator expand $a to
   > ($a,$a,$a), but (1) to (1,undef,undef)? Oh, it's because hyper-ops
   > expand an arg if it is short on *dimensions* and not *elements*.

Bingo.

   > (1) gets expanded to (1,undef,undef) by auto-vivification of list
   > elements, and not by action of the hyper-op, correct?

Yes.

Damian

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About