Re: reduce via ^ again

2002-09-09 Thread Damian Conway
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

reduce via ^ again

2002-09-07 Thread John Williams
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, ..

Re: reduce via ^

2001-10-11 Thread Larry Wall
[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

Re: reduce via ^

2001-10-11 Thread Damian Conway
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: > > $

Re: reduce via ^

2001-10-11 Thread Piers Cawley
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 ^

Re: HOF positional args (was Re: reduce via ^)

2001-10-10 Thread Damian Conway
> > @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.

HOF positional args (was Re: reduce via ^)

2001-10-10 Thread Jeremy Howard
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

Re: reduce via ^

2001-10-10 Thread Damian Conway
> 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

Re: reduce via ^

2001-10-10 Thread Colin Meyer
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

Re: reduce via ^

2001-10-10 Thread Damian Conway
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

Re: reduce via ^

2001-10-10 Thread Damian Conway
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: >

Re: reduce via ^

2001-10-10 Thread Damian Conway
> >> $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

Re: reduce via ^

2001-10-10 Thread Colin Meyer
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:

Re: reduce via ^

2001-10-10 Thread Colin Meyer
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

Re: reduce via ^

2001-10-10 Thread Bart Lateur
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

Re: reduce via ^

2001-10-10 Thread Jonathan Scott Duff
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

Re: reduce via ^

2001-10-10 Thread Aaron Sherman
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

Re: reduce via ^

2001-10-10 Thread Colin Meyer
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

Re: reduce via ^

2001-10-10 Thread Jonathan Scott Duff
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

Re: reduce via ^

2001-10-10 Thread Colin Meyer
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

Re: reduce via ^

2001-10-10 Thread Damian Conway
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

reduce via ^

2001-10-10 Thread John Williams
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