Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: How to code this?

by CountZero (Bishop)
on Nov 14, 2011 at 23:09 UTC ( #938040=note: print w/replies, xml ) Need Help??

in reply to How to code this?

Perhaps an Array of Arrays is a better kind of storage?

There will be "holes" in your AoA of course, but you can use a sliding window of (for example) length 4 and it will be easy to see what needs to be dropped or added. The low limit needs to be dropped and the upper limit needs to be added and it is easy to check if they contain anything or not.


A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: How to code this?
by herveus (Parson) on Nov 15, 2011 at 14:31 UTC

    Given subsequent clarifications, I think this may be a very effective approach. If you look at the first n items in the array, you will get the entire group each time. Once you have handled a set, shift the first element off and any subsequent empty elements. Lather, rinse, repeat.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://938040]
and the questions are moot...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2018-04-26 02:40 GMT
Find Nodes?
    Voting Booth?