[Belfast-pm] unshift-y bop-op-op-op, just blows me away </hair>

Tony Bowden tony-belfast at kasei.com
Thu Dec 23 09:39:33 CST 2004


On Thu, Dec 23, 2004 at 03:32:58PM +0000, Stray Toaster wrote:
> > perl -e '@l=1..10; warn "@{[@l[- at l+1..0]=@l]}\n" for @l'
> > (and yes, I know you could golf this further...)
> > Although, surely you should really want @l[-1.. at l-2]?

> I didn't want it golfed. 

That's why I didn't golf it. All that whitespace was needless :)
And you could assign later as well:

	perl -e'warn"@{[@l[- at l+1..0]=@l]}\n"for at l=1..10'

> I just wanted to rotate a list. 

@l[- at l+1..0]=@l; 
or 
@l[-1.. at l-2]=@l;

Depending on the preferred direction.

> The 1 .. 10 bit was red herring. The list could be any size, really.

That's why I fixed your duplication of the 1..10 :)

Tony


More information about the Belfast-pm mailing list