for-loop

Flow control in a batch file

Reference Iterating arrays in a batch file I have the following: for /f "tokens=1" %%Q in ('query termserver') do ( if not ERRORLEVEL ( echo Checking %%Q for /f "tokens=1" %%U in ('query user %UserID% /server:%%Q') do (echo %%Q) ) ) When running query termserver from the command line, the first two lines are: ...

Java: minimum number of operations for conjunctive inequalities?

I try to simplify conditionals in: for ( int t=0, size=fo.getPrintViewsPerFile().size(); t<size && t<countPerFile; t++) { // ... } , more precisely: t<s && t<c You need to compare two times, then calc the boolean value from them. Is there any simpler way to do it? If no, how can you prove it? I can simplify...

Reversing a for loop... want to print numbers in reverse

How would I change this loop to print prime number in reverse... starting from the biggest one first int main(){ bool prime; for( int i=3; i<=10000; i++){ prime = true; for(int n=2; n<=i-1; n++){ if( i%n == 0){ prime = false; } } if(prime){ cout...

For loop index out of range ArgumentOutOfRangeException when multithreading

I'm getting some strange behavior... when I iterate over the dummyText List in the ThreadTest method I get an index out of range exception (ArgumentOutOfRangeException), but if I remove the threads and I just print out the text, then everything works fine. This is my main method: public static Object sync = new Object(); static void Ma...

How do I break out of a loop in Scala?

For Problem 4 of Project Euler How do I break out a loop? var largest=0 for(i<-999 to 1 by -1) { for (j<-i to 1 by -1) { val product=i*j if (largest>product) // I want to break out here else if(product.toString.equals(product.toString.reverse)) largest=largest max product } } And does anyone know how to turn nested for l...

Why doesn't this for-loop execute?

I'm writing a program for an exercise that will read data from a file and format it to be readable. So far, I have a bit of code that will separate a header from the data that goes under it. Here it is: int main() { ifstream in("records.txt"); ofstream out("formatted_records.txt"); vector<string> temp; vector<string> hea...

Python iterator question

I have this list: names = ['john','Jonh','james','James','Jardel'] I want loop over the list and handle consecutive names with a case insensitive match in the same iteration. So in the first iteration I would do something with'john' and 'John' and I want the next iteration to start at 'james'. I can't think of a way to do this using ...

How would I yield an immutable.Map in Scala?

I have tried this but it does not work: val map:Map[String,String] = for { tuple2 <- someList } yield tuple2._1 -> tuple2._2 How else would I convert a List of Tuple2s into a Map? ...

FFMPEG iPhone using gas-preprocessor

Hi, I got the latest version of FFMPEG and gas-preprocessor, and i am trying to build them libraries for iPhone. I put the gas-preprocessor.pl file in my usr/bin folder, and try to configure my ffmpeg with this command. ./configure --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.2.1 --as='gas-prepro...

LotusScript - Setting element in for loop

I have an array set up Dim managerList(1 To 50, 1 To 100) As String what I am trying to do, is set the first, second, and third elements in the row managerList(index,1) = tempManagerName managerList(index,2) = tempIdeaNumber managerList(index,3) = 1 But get an error when I try to do that saying that the object variable is not ...

PHP foreach loop through multidimensional array

I have an multidimensional array, how can I use it? I want to use each separate array in a for loop. What I want to achive is to be able to put each part in my database like entry in db no. 0 -> 1 and 4 entry in db no. 1 -> 5 and 6 entry in db no. 2 -> 1 and 4 and 5 and 6 I have this code: <?php print_r($calculatie_id); for ...

Trying to create an infinite for loop that can stop using function doIt()

Hey guys, I'm new to javascript and I'm doing a project for my final in class. I need to make it so this game engine I manipulated causes the generation button to go for an infinite loop. I also need to stop it using (Reset==1). Any help? Here's the code I have so far if that helps: function generation() { for(y2=0; y2<2500; y2++) ...

Types of Nested Loops in Java

Hi guys. I have a simple question. I have to find out many nested loops as possible in java. I have something like for loop and if statement inside. i know that we can do like if{if{if{if{ something like that too. just need some more idea of more types of nested loops. if you can write down some examples. I'll be very glad. thank you....

Listing down stored records localStorage | Google Chrome Extensions

How do I get to list down the stored records in the for loop? Basically I want it to list down the records like this: '<div id="record_' + number + '">' + localstorage value + '</div>' The number in the class should add 1 every record, e.g. 1, 2, 3, 4 every record it lists down, and so on. The localstorage value should show the loc...

for loop with count from array, limit output? PHP

print '<div id="wrap">'; print "<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\">"; for($i=0; $i<count($news_comments); $i++) { print ' <tr> <td width="30%"><strong>'.$news_comments[$i]['comment_by'].'</strong></td> <td width="70%">'.$news_comments[$i]['comment_date'].'</td> </tr...

JavaScript for loop index strangeness

I'm relatively new to JS so this may be a common problem, but I noticed something strange when dealing with for loops and the onclick function. I was able to replicate the problem with this code: <html> <head> <script type="text/javascript"> window.onload = function () { var buttons = document.getElementsByTagName('a'); for (v...

Mulitple variable containing "for loop" is not working in my code...

Below is the code I am working with and the last for loop i am iterating is not working... I think i am doing something wrong using multiple variable in a for loop,also I m aware of the fact that it can be done. $updaterbk = "SELECT j1. * FROM jos_audittrail j1 LEFT OUTER JOIN jos_audittrail j2 ON ( j1.trackid != j2.trackid AND j1.fie...

For loop to extract info from a structure doesn't work?

I have a structure in matlab that has a value of <1x1 struct>., its name is figurelist. Inside that structure, there is a field called images. Inside images, I have 25 images that have the name img1, img2, img3, ..... , img25. Now I made a for loop to extract those images, I basically did: For K=1:25 image(figurelist.images.imgK)...

Is there are any api's available to MMS through any application of iPhone

I am designing iPhone application project. In that I need to send MMS through that application.Is there are available api's to create MMS and send it like an email? ...

can i changed for loop index variable inside the loop in Matlab???

hi every one. i need to change my loop variable inside the iterationa as ihave to acces array elements in the loop which is changing w.r.t size inside the loop. ashort piece of code is that: que=[]; que=[2,3,4]; global len; len=size(que,2) x=4; for i=1:len if x<=10 que(x)= 5; len=size(que,2) x=x+1; end end que a...