Re: Multi-d array transforms (was Re: Array rotate)

2009-06-13 Thread John M. Dlugosz
Larry Wall larry-at-wall.org |Perl 6| wrote: On Sat, Jun 13, 2009 at 02:49:10PM -0500, John M. Dlugosz wrote: Wow. The overarching logic for list assignment would have to compare the containers and the arguments in the capture before doing the list assignment to each container, in order t

Re: Multi-d array transforms (was Re: Array rotate)

2009-06-13 Thread Larry Wall
On Sat, Jun 13, 2009 at 02:49:10PM -0500, John M. Dlugosz wrote: > Wow. The overarching logic for list assignment would have to compare > the containers and the arguments in the capture before doing the list > assignment to each container, in order to avoid cloning all the > containers on th

Re: Multi-d array transforms (was Re: Array rotate)

2009-06-13 Thread John M. Dlugosz
Daniel Carrera daniel.carrera-at-theingots.org |Perl 6| wrote: In addition, the current @a.shift is useful because it returns the element that was removed from the array, so you can do something with it: The change to the library synopses was checked in before you posted that, if I recall the

Re: Array Dimensionality (Was: Re: Multi-d array transforms (was Re: Array rotate))

2009-06-13 Thread John M. Dlugosz
Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote: So, how do I deal with a multidim array? Well, TIMTOWTDI... my @a = 1,[2,[3,4]]; say @a[1][1][1]; say @a[1;1;1]; # I'm not sure this is correct I think that it should be. That is, multi-dim subscript is always the same as chained subscrip

Re: Array Dimensionality (Was: Re: Multi-d array transforms (was Re: Array rotate))

2009-06-13 Thread John M. Dlugosz
Larry Wall larry-at-wall.org |Perl 6| wrote: Alternately, we leave @@ (or @%) meaning ¢ and instead let some other syntax take over the "pay attention to the capture's structure" semantics from @@. Maybe it's another use for the zen slice: "pay attention to the capture's structure" is a c

Re: Multi-d array transforms (was Re: Array rotate)

2009-06-13 Thread John M. Dlugosz
Larry Wall larry-at-wall.org |Perl 6| wrote: We also need to consider the "dimension" of referentiality. I can see three levels here. Given @a.mung the .mung could return A) a modified @a (treat @a as mutable) B) a new array (treat @a as immutable) C) a remapped array whose e

Re: Array rotate

2009-06-13 Thread John M. Dlugosz
Jon Lang dataweaver-at-gmail.com |Perl 6| wrote: On Fri, Jun 12, 2009 at 10:02 AM, yary wrote: I am tickled pink to see an Array "rotate" method in the settings spec S032, as I was thinking of writing up a little discussion on the very topic. Has there been discussion on using ar

Re: Multi-d array transforms (was Re: Array rotate)

2009-06-13 Thread Jon Lang
On Fri, Jun 12, 2009 at 11:23 PM, Matthew Walton wrote: > Although some things may be able to be implemented far more > efficiently if they know that they're being called with infix:<.=> and > not with infix:<.>. Last I checked, Perl 6 had some types that are mutating and others that aren't (e.g.,

Re: Multi-d array transforms (was Re: Array rotate)

2009-06-13 Thread Daniel Carrera
Larry Wall wrote: Nevertheless, for any major methods borrowed from Perl 6, I'm not inclined to change them that drastically. Much more likely to define them as sugar for the more general list operators: .push means .=append .unshiftmeans .=prepend .splice means

Re: Multi-d array transforms (was Re: Array rotate)

2009-06-12 Thread Matthew Walton
On Sat, Jun 13, 2009 at 1:08 AM, Larry Wall wrote: > Nevertheless, for any major methods borrowed from Perl 6, I'm not > inclined to change them that drastically.  Much more likely to > define them as sugar for the more general list operators: > >    .push       means   .=append >    .unshift    me

Re: Multi-d array transforms (was Re: Array rotate)

2009-06-12 Thread Larry Wall
On Sat, Jun 13, 2009 at 01:25:23AM +0200, Daniel Carrera wrote: > Damian Conway wrote: >> In fact, I would even be happy with requiring @a.=push and @a.=shift, if >> it meant that there were *no* special cases. One extra character is a >> small price to pay for perfect SWIM (and not just "Say What

Re: Multi-d array transforms (was Re: Array rotate)

2009-06-12 Thread Daniel Carrera
Damian Conway wrote: In fact, I would even be happy with requiring @a.=push and @a.=shift, if it meant that there were *no* special cases. One extra character is a small price to pay for perfect SWIM (and not just "Say What I Mean", the real benefit is the other SWIM: "See What I Meant"). I don

Re: Multi-d array transforms (was Re: Array rotate)

2009-06-12 Thread Damian Conway
Larry mused: >   �...@a.mung > > the .mung could return > >    A) a modified @a (treat @a as mutable) >    B) a new array (treat @a as immutable) >    C) a remapped array whose elements refer back to @a's elements > > Currently .rotate is defined as A, but I could easily switch it to B, I, for on

Re: Array Dimensionality (Was: Re: Multi-d array transforms (was Re: Array rotate))

2009-06-12 Thread Larry Wall
On Fri, Jun 12, 2009 at 04:00:10PM -0300, Daniel Ruoso wrote: : Em Sex, 2009-06-12 às 11:52 -0700, Jon Lang escreveu: : > On Fri, Jun 12, 2009 at 11:51 AM, Daniel Ruoso wrote: : > > Ok, There's one thing that is not clear in the thread, which is when an : > > array is multidimensional or not... : >

Re: Multi-d array transforms (was Re: Array rotate)

2009-06-12 Thread Larry Wall
We also need to consider the "dimension" of referentiality. I can see three levels here. Given @a.mung the .mung could return A) a modified @a (treat @a as mutable) B) a new array (treat @a as immutable) C) a remapped array whose elements refer back to @a's elements Currently

Re: Array Dimensionality (Was: Re: Multi-d array transforms (was Re: Array rotate))

2009-06-12 Thread Daniel Ruoso
Em Sex, 2009-06-12 às 11:52 -0700, Jon Lang escreveu: > On Fri, Jun 12, 2009 at 11:51 AM, Daniel Ruoso wrote: > > Ok, There's one thing that is not clear in the thread, which is when an > > array is multidimensional or not... > > For instance: > > @a = (1, 2, 3; 4, 5, 6; 7, 8, 9); > > Will produce

Re: Array Dimensionality (Was: Re: Multi-d array transforms (was Re: Array rotate))

2009-06-12 Thread Jon Lang
On Fri, Jun 12, 2009 at 11:51 AM, Daniel Ruoso wrote: > Ok, There's one thing that is not clear in the thread, which is when an > array is multidimensional or not... > > For instance: > > �...@a = (1, 2, 3; 4, 5, 6; 7, 8, 9); > > Will produce a flatten array, because list assignment causes flatteni

Array Dimensionality (Was: Re: Multi-d array transforms (was Re: Array rotate))

2009-06-12 Thread Daniel Ruoso
Ok, There's one thing that is not clear in the thread, which is when an array is multidimensional or not... For instance: @a = (1, 2, 3; 4, 5, 6; 7, 8, 9); Will produce a flatten array, because list assignment causes flattening, so the dimensionality was lost. It is important to remember that

Re: Multi-d array transforms (was Re: Array rotate)

2009-06-12 Thread Jon Lang
On Fri, Jun 12, 2009 at 10:58 AM, yary wrote: >> * you can rearrange the dimensions themselves (e.g., transpose). > > Reflecting on 2 or more axes creates a transposition. No, it doesn't: @a = (1, 2, 3; 4, 5, 6; 7, 8, 9); Reflecting on two axes would result in: @a = (9, 8, 7; 6, 5, 4; 3

Re: Multi-d array transforms (was Re: Array rotate)

2009-06-12 Thread yary
I think any 1D op could be transformed to "do the right thing" on a multidimensional array, with some sort or hyperop or reduction transform. Rotate, reverse, even add/subtract can be told "do your thing along this vector" and return a usefully dimensioned result. Need to work on other things at t

Multi-d array transforms (was Re: Array rotate)

2009-06-12 Thread yary
Putting this in a new thread, as I'd like to discuss it separately from refinements to Array.rotate On Fri, Jun 12, 2009 at 10:11 AM, Jon Lang wrote: > With a multi-dimensional array, a number of transforms can be considered: > > * you can rearrange the elements along a given dimension (e.g., rota

Re: Array rotate

2009-06-12 Thread Jon Lang
On Fri, Jun 12, 2009 at 10:02 AM, yary wrote: > I am tickled pink to see an Array "rotate" method in the settings spec > S032, as I was thinking of writing up a little discussion on the very > topic. > > Has there been discussion on using array rotate on multi-dimensiona

Array rotate

2009-06-12 Thread yary
I am tickled pink to see an Array "rotate" method in the settings spec S032, as I was thinking of writing up a little discussion on the very topic. Has there been discussion on using array rotate on multi-dimensional arrays? Being able to pass in a vector as the amount to rotate would