John Williams wrote:
> Back in October I suggested that $a ^+= @b would act like reduce,
> but in discussion
> it was decided that it would act like length
> I now pose the question: Is ^+= a "hyper assignment operator" or an
> "assignment hyper operator"?
> with a scalar involved
> the me
Apologies for trying to resuscitate this old horse, but a new idea
occurred to me.
Back in October I suggested that $a ^+= @b would act like reduce,
but in discussion
it was decided that it would act like length, by the interpretation:
$a ^+= @b
$a = $a ^+ @b
$a = ($a, $a, $a, ..
[EMAIL PROTECTED] writes:
: Given:
:
:> $a = 1;
:> @b = (1, 2, 3);
:
: Damian suggested that:
:
:> $a = $a ^+ @b
:>
:> becomes:
:>
:> $a = ($a, $a, $a) ^+ (1, 2, 3)
:> $a = (1, 1, 1) ^+ (1, 2, 3)
:> $a = (2, 3, 4)
:> $a = 4;
:
: Whereas Piers thought
Given:
> $a = 1;
> @b = (1, 2, 3);
Damian suggested that:
> $a = $a ^+ @b
>
> becomes:
>
> $a = ($a, $a, $a) ^+ (1, 2, 3)
> $a = (1, 1, 1) ^+ (1, 2, 3)
> $a = (2, 3, 4)
> $a = 4;
Whereas Piers thought that:
> $a = $a ^+ @b
>
> becomes:
>
> $
Damian Conway <[EMAIL PROTECTED]> writes:
> Colin exemplifies:
>
>> $a = 1;
>> @a = (1);
>> @b = (1, 2, 3);
>> @c = (4, 5, 6);
>>
>> $a = $a ^+ @b;
>> @a = @a ^+ @b;
>>
>> print $a; # 7
>
> No. It will (probably) print: 4. Because:
>
> $a = $a ^
> > @a ^+= reduce {$^a+$^b} @b;
>
> What's this? Are positional args to HOFs now alphabetic rather than
> numeric?
No. I just chose to used named placeholders, since they're more easily
followed in this example.
> cf. http://dev.perl.org/rfc/23.html#Positional_placeholders
cf.
Damian Conway wrote:
> @a ^+= reduce {$^a+$^b} @b;
What's this? Are positional args to HOFs now alphabetic rather than numeric?
cf. http://dev.perl.org/rfc/23.html#Positional_placeholders
> 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 i
According to Damian:
>
> Colin exemplifies:
>
>> $a = 1;
>> @a = (1);
>> @b = (1, 2, 3);
>> @c = (4, 5, 6);
>>
>> $a = $a ^+ @b;
>> @a = @a ^+ @b;
>>
>> print $a; # 7
>
> No. It will (probably) print: 4. Because:
>
>
>> print @a; # 7 or 2?
>
> Pri
Colin exemplifies:
> $a = 1;
> @a = (1);
> @b = (1, 2, 3);
> @c = (4, 5, 6);
>
> $a = $a ^+ @b;
> @a = @a ^+ @b;
>
> print $a; # 7
No. It will (probably) print: 4. Because:
$a = $a ^+ @b;
becomes:
$a = ($a,$a,$a) ^+ @b;
which is:
$a
Aaron asked:
> I'm wondering about some other operators Will there be a ^?? operator?
I believe that there will be a hyperoperator for *every* operator.
> I might, for example, say:
>
>@a = @b ^?? 'yea' :: 'nay';
>
> Which I would expect to be the same as:
>
> >> $a ^+= @list; # should sum the elements of @list
>
> Does this mean that
>
> @a ^+= @b;
>
> will add every value of @b to every value of @a?
No. The rule is that a hyperoperator replicates its lower-dimensional
operand up to the same number of dimensions as it
On Wed, Oct 10, 2001 at 03:41:18PM -0700, Colin Meyer wrote:
>
> Maybe this illustrates my confusion:
>
> $a = 1;
> @a = (1);
> @b = (1, 2, 3);
> @c = (4, 5, 6);
>
> $a = $a ^+ @b;
> @a = @a ^+ @b;
>
> print $a; # 7
> print @a; # 7 or 2?
Or, after re-reading the apocolypse again, it seems:
On Wed, Oct 10, 2001 at 04:34:14PM -0500, Jonathan Scott Duff wrote:
> On Wed, Oct 10, 2001 at 02:23:33PM -0700, Colin Meyer wrote:
> [ @a ^+= @b ]
> > What I'd expect is more like:
> >
> > foreach my $elem (@a) {
> > $elem ^+= @b;
> > }
>
> Hrm. Why would you expect that when you'd ha
On Wed, 10 Oct 2001 14:23:33 -0700, Colin Meyer wrote:
>> > Does this mean that
>> >
>> > @a ^+= @b;
>> >
>> > will add every value of @b to every value of @a?
>What I'd expect is more like:
>
> foreach my $elem (@a) {
> $elem ^+= @b;
> }
>
If you want that effect, apply "scalar" on t
On Wed, Oct 10, 2001 at 02:23:33PM -0700, Colin Meyer wrote:
[ @a ^+= @b ]
> What I'd expect is more like:
>
> foreach my $elem (@a) {
> $elem ^+= @b;
> }
Hrm. Why would you expect that when you'd have written as you just
did? Would you also expect
@a = @b ^+ @c;
to mean
On Wed, Oct 10, 2001 at 01:27:35PM -0700, Colin Meyer wrote:
> On Wed, Oct 10, 2001 at 09:42:58PM +1000, Damian Conway wrote:
> >
> > John observed:
> >
> >> I just read Apocalypse and Exegesis 3, and something stuck out at me
> >> because of its omission, namely using hyper operators
On Wed, Oct 10, 2001 at 04:04:18PM -0500, Jonathan Scott Duff wrote:
> On Wed, Oct 10, 2001 at 01:27:35PM -0700, Colin Meyer wrote:
> >
> > Does this mean that
> >
> > @a ^+= @b;
> >
> > will add every value of @b to every value of @a?
>
> That's what I'd expect it to do. Well ... that's ass
On Wed, Oct 10, 2001 at 01:27:35PM -0700, Colin Meyer wrote:
> On Wed, Oct 10, 2001 at 09:42:58PM +1000, Damian Conway wrote:
> >
> > John observed:
> >
> >> I just read Apocalypse and Exegesis 3, and something stuck out at me
> >> because of its omission, namely using hyper operators
On Wed, Oct 10, 2001 at 09:42:58PM +1000, Damian Conway wrote:
>
> John observed:
>
>> I just read Apocalypse and Exegesis 3, and something stuck out at me
>> because of its omission, namely using hyper operators for reduction.
>>
>> $a ^+= @list; # should sum the elements of
John observed:
> I just read Apocalypse and Exegesis 3, and something stuck out at me
> because of its omission, namely using hyper operators for reduction.
>
> $a ^+= @list; # should sum the elements of @list
>
> Larry says @a ^+ 1 will replicate the scalar value for all
I just read Apocalypse and Exegesis 3, and something stuck out at me
because of its omission, namely using hyper operators for reduction.
$a ^+= @list; # should sum the elements of @list
Larry says @a ^+ 1 will replicate the scalar value for all a's, and Damian
talks about doing summation with
22 matches
Mail list logo