for-loop

scope of variables when using for-loop in java - eclipse / compiler error?

I've written the following code: for(int layer = 0; layer <countLayers; layer++); { List<Sprite> spritesInLayer = sceneGraph.getLayer(layer); } when i compile this snippet, I get an error, that in the line within the for-Loop, eclipse complains that 'layer' is an unknown symbol [... = sceneGraph.getLayer(layer);] and wants me to i...

script to generate diffs between consecutive commits, and writing them to file

In order to view changes or diffs between commits, i use the following from the command line: svn diff -r 3000:3025 > daychanges.diff I want to modify the command so that it generates diffs between successive commits, concatenates them and outputs to file, something like svn diff -r 3000:3001 > daychanges.diff svn diff -r 3001:3002 >...

is it possible to use bash to access more than one array in a for loop

I'm trying to write a bash script that will let me download multiple web pages using curl. For each webpage, I want to be able to pass curl the page and the referer link. I want to be able to supply multiple webpages at once. In other words, I want to be able to loop through the webpages I supply the script, and for each page, pass the ...

vb.net insert record into dataset cell from a loop

For j = 0 To wcData.Tables(0).Rows.Count - 1 For i = 900 To 1700 wcData.Tables("db").Rows(j)("range") = i Next Next trying to insert "i" into each column cell of "range" any suggestion. Thanks. ...

Function with loop calling itself

I have a function, in which there is a loop which calls up the function. function displayItem(item, isChild) { if (isChild) { writeOutput('<li>' & item.name & '</li>'); } else { writeOutput('<li>' & item.name); } try { if (item.hasChild) { writeOutput('<ul>'); ...

Opposite of Python for ... else

The following python code will result in n (14) being printed, as the for loop is completed. for n in range(15): if n == 100: break else: print(n) However, what I want is the opposite of this. Is there any way to do a for ... else (or while ... else) loop, but only execute the else code if the loop did break? ...

java - do while string is NOT null or empty

OK so here is some logic thinking... What I am trying to do is loop through strings until I hit a null/empty string.. then STOP. All while putting those strings inside a string array... Here is a sample of the code. I know it's wrong but hopefully to give you an idea of what I am trying to achieve: int i; wepN = new String[100]; int we...

does advanced for each loop in java call method that returns an array to iterate over every single time?

His, I have a question to the advanced for loop in java. If there is a method call Method.returnArray() and I iterate over the array with for (ArrayElement e : Method.returnArray()) { //do smth } will the .returnArray() be called by every iteration? Thanks. ...

Monotonify (list-munging) without a For loop.

For or While loops in Mathematica code always make me feel a little dirty but I was confusing myself trying to do some list munging all functional-like, and resorted to this: (* # Given a list of {x,y} pairs, transform the data as follows: every time # there's a decrease in y-value from one datapoint to the next, say {x1,Y} # fo...

Is for keyword obsolete like goto in modern object-oriented languages?

Hi, Is for keyword obsolete or may become obsolete just as goto in languages like C# or Java? In a few years, will it be strange and suspicious to see an object-oriented code which uses for, like today, it's very suspicious to see gotos? In other words, is there any reason to know and use for in programs? I notice that there are a b...

Objective C - NSArray and For loop structure

Hi everyone, Work got in the way of learning Objective C but i'm back at it now and this has been driving me crazy. This is my code: i=0; for (i=0;[photoList count]; i++) { NSLog(@"%i",i); NSLog(@"%@",[photoList objectAtIndex:i]); NSString *fileName = [photoList objectAtIndex:i]; sendImage = [UIImag...

JavaFX for iphone ipad

i need to know that can JavaFX application run into IPHONE IPAD? Is there any JavaFX runtime in these device. ...

vb.net For Each loop

I would like to loop through two lists using a For each loop. dim data as list(of pointpairlist) For each recLine in records For Each chan In recLine.channels and d in data d.add( func(chan) ) Next next note: each record line has one sample from each channel recorded. ie each record line is a slice of a 32 sensor recordi...

Python for-loop counter error

Hello! I am attempting to script a short code to figure out the number of days it takes to reach a given principal in the bank due to daily interest. Using my code below does not yield any errors when run in IDLE, but the counter returns 0. Any ideas what I missed? def main(): # irrelevant code elided by msw, Bal, Int and Tar are nu...

Do you choose Linq over Forloops?

Given a datatable containing two columns like this: Private Function CreateDataTable() As DataTable Dim customerTable As New DataTable("Customers") customerTable.Columns.Add(New DataColumn("Id", GetType(System.Int32))) customerTable.Columns.Add(New DataColumn("Name", GetType(System.String))) Dim row1 = customerTable.New...

Good documentation on structure tcp_info

Hi folks, I am working on getting the performance parameters of a tcp connection and one these parameters is the bandwidth. I am intending to use the tcp_info structure supported from linux 2.6 onwards, which holds the meta data about a tcp connection. The information can be retrieved using the getsockopt() function call on tcp_info. I h...

How to add a for attribe to a div like label's for?

So what I want is a div what points to an input or a div with contentEditable=true. So if a click on the div then jumps inside the input. ...

Batch file to delete specific folders

I need a batch file that will recursively remove all directories with a certain filename. This is what I have so far and its not working. FOR /D /r %%G IN ("*.svn") DO DEL %%G Thanks! ...

How to initialize several variables in a for (;;) loop in C?

I thought one could initialize several variables in a for loop: for (int i = 0, char* ptr = bam; i < 10; i++) { ... } But I just found out that this is not possible, gcc gives the following error: error: expected unqualified-id before 'char' Is it really true that you can't initialize variables of different types in a for loop? ...

Python: is there a C-like for loop available?

Can I do something like this in Python? for (i = 0; i < 10; i++): if someCondition: i+=1 print i I need to be able to skip some values based on a condition EDIT: All the solutions so far suggest pruning the initial range in one way or another, based on an already known condition. This is not useful for me, so let me explain ...