Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: How to get this not the usual round robin looping: Boustrophedon distribution

by Discipulus (Canon)
on Oct 13, 2015 at 09:39 UTC ( [id://1144662]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to get this not the usual round robin looping
in thread How to get this not the usual round robin looping

As already said in chat congratulation Athanasius for your Boustrophedon distribution function.I thought your crucial line was difficult to read and my hubris lead me think i could semplify it by playing with the index of @A..

..as always i endend with a hyper complicated and cryptic solution, even if my hubrys is partially satisfied: anyway TIMTOWTDI!!
#! perl use strict; use warnings; use Data::Dump; my @A = qw ( H1 H2 H3 H4); # original set my @B = qw (1 2 3 4 5 6 7 8 9 10); # as per OP my %h; my $i = 0; while (@B) { push @{$h{$A[$i]}},shift @B; $i == $#A ? $i = -1 : $i == -$#A-1 ? $i = 0 : $i < 0 ? $i-- : $i+ ++; } dd %h;


L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1144662]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-19 03:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found