[clue-tech] increment weather
dennisjperkins at comcast.net
dennisjperkins at comcast.net
Tue Feb 23 07:29:59 MST 2010
----- Original Message -----
From: "David L. Anselmi" <anselmi at anselmi.us>
To: "CLUE technical discussion" <clue-tech at cluedenver.org>
Sent: Monday, February 22, 2010 11:05:11 PM GMT -07:00 US/Canada Mountain
Subject: Re: [clue-tech] increment weather
David L. Willson wrote:
> I have a loop-counter that I want to increment from within the loop, having found that the next
> two items in the array I'm iterating through belong to me. How can I do that?
>
> This illustrates my problem:
>
> for i in $(seq 10)
What Dennis said. Your i isn't a loop counter, it's a list iterator that gets assigned at the
beginning of each pass. Compare to:
for i in foo bar baz
I think in PHP there's an indexer that you can tweak on arrays but I don't think so in shell.
But even on Dennis's form (or Jed's while loop, which is essentially the same) I wonder whether
in-loop mods are a good idea. Remember what Kernighan said about debugging being harder than coding...
Good point. I have used it, but usually it's better to start a new iteration. I think bash has a command for this purpose. It might be called "continue".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cluedenver.org/pipermail/clue-tech/attachments/20100223/1636a1fb/attachment.html
More information about the clue-tech
mailing list