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

Stray Toaster mwk at stray-toaster.co.uk
Thu Dec 23 09:32:58 CST 2004


On Thu, Dec 23, 2004 at 03:28:46PM +0000, tony-belfast at kasei.com wrote:
> On Thu, Dec 23, 2004 at 02:25:21PM +0000, Stray Toaster wrote:
> > This is annoying me. A better way please?
> > perl -e '@l = (1..10); do { warn join(" ", @l), "\n"; unshift @l, pop
> > @l; } for (0 .. 10);'
> 
> In what way, better?

I don't know, there just seems something off to me about it. It could be
what I had for lunch.
> 
> 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. I just wanted to rotate a list. The 1 .. 10 bit
was red herring. The list could be any size, really.

m.

-- 
In every cry of every Man
In every Infant's cry of fear,
In every voice, in every ban,
The mind-forg'd manacles I hear.

--
Gotta have a blog. It is the law.
http://www.stray-toaster.co.uk/blog/


More information about the Belfast-pm mailing list