for-loop

Dividing sections inside an omp parallel for : OpenMP

Hi, I have a situation like: #pragma omp parallel for private(i, j, k, val, p, l) for (i = 0; i < num1; i++) { for (j = 0; j < num2; j++) { for (k = 0; k < num3; k++) { val = m[i + j*somenum + k*2] if (val != 0) for (l = start; l <= end;...

Is it possible to declare two variables of different types in a for loop?

Is it possible to declare two variables of different types in the initialization body of a for loop in C++? For example: for(int i=0,j=0 ... defines two integers. Can I define an int and a char in the initialization body? How would this be done? ...

Differences between a while loop and a for loop in PHP?

I'm reading an ebook on PHP right now, and the author noted that the difference between a while loop and a for loop is that the for loop will count how many times it runs. So take this: <?php for ($i = 1; $i < 10; $i = $i + 1) { print "Number $i\n"; } ?> But wouldn't this be the same as <?php $i = 1; wh...

Help me to understand the termination parameter of this C++ for loop

I do not understand the termination parameter of this for loop. What does it mean? Specifically, what do the ?, ->, and : 0 represent? for( i = 0; i < (sequence ? sequence->total : 0); i++ ) ...

Reading into directory, unix shell script

I am trying to analyze the files/directories inside of a directory using a shell script, for example if the file is readable, if it is a file, if it is a directory, etc. My script is set up to take a directory as input. so I would type 'file.sh directoryname'. However, when I create a for loop to analyze the files, it analyzes the files ...

How can I use the FOR attribute of a LABEL tag without the ID attribute on the INPUT tag

Is there a solution to the problem illustrated in the code below? Start by opening the code in a browser to get straight to the point and not have to look through all that code before knowing what you're looking for. <html> <head> <title>Input ID creates problems</title> <style type="text/css"> #prologue, #summary { margin: 5em;...

For Loops in MIPS assembly

I'm having problems getting my processor to simulate correctly and I think I've narrowed it down to the program I'm giving it. 1. li $R1, 0 2. li $R2, 0x100 3. li $R6, 1 4. li $R8, 0 5. li $R9, 20 6. lw $R3, 0($R1) 7. lw $R4, 4($R1) 8. add $R5, $R3, $R4 9. srlv $R5, $R5, $R6 10. sw $R5, 0($R2) 11. ad...

[Android] For-Loop Performance Oddity

I just noticed something concerning for-loop performance that seems to fly in the face of the recommendations given by the Google Android team. Look at the following code: package com.jackcholt; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class Main extends Activity { @Override publi...

Why doesen't the number 2 work in this for-loop?

Hello. I have a function that runs trough each element in an array. It's hard to explain, so I'll just paste in the code here: NSLog(@"%@", arraySub); for (NSNumber *favoriteThing in arrayFav){ int favoriteLoop = [favoriteThing intValue] + favCount; NSLog(@"%d", favoriteLoop); id arrayFavObject = [array objectAtIndex:f...

MS Access query for time

Following data and using MS Access with VB6 UserID UserName LogTime LogDate 1 S 9:00 21/5/2010 1 S 10:00 21/5/2010 1 S 11:00 21/5/2010 1 S 12:00 21/5/2010 1 S 14:00 21/5/2010 1 S 17:00 21/5/2010 Need Output as in below 6 co...

Which is better Java programming practice for looping up to an int value: a converted for-each loop or a traditional for loop?

Hi folks, Given the need to loop up to an arbitrary int value, is it better programming practice to convert the value into an array and for-each the array, or just use a traditional for loop? FYI, I am calculating the number of 5 and 6 results ("hits") in multiple throws of 6-sided dice. My arbitrary int value is the dicePool which re...

Python Beginner: Selective Printing in loops

Hi there. I'm a very new python user (had only a little prior experience with html/javascript as far as programming goes), and was trying to find some ways to output only intermittent numbers in my loop for a basic bicycle racing simulation (10,000 lines of biker positions would be pretty excessive :P). I tried in this loop several 'rea...

How do I make this loop all children recursively?

I have the following: for (var i = 0; i < children.length; i++){ if(hasClass(children[i], "lbExclude")){ children[i].parentNode.removeChild(children[i]); } }; I would like it to loop through all children's children, etc (not just the top level). I found this line, which seems to do that: for(var m = n.firstChild; m != nu...

Page curl left and right for uiwebview with html contents

I am working on a epub book reader application and displaying the contents of book in web view and i want to give a horizontal page curl effect for that just a turning the page of a real book. I couldnt find any tutorials for that . Help is appreciated ...

How to get array identifier in javascript?

Hi, how can I get the indentifier of an associative array (not Array object) in a for loop? like so: var i = 0; for(i=0;i<=myArray;i++) { if(myArray.ident == 'title') alert('The title is ' + myArray['title']); } ...

How do I create a controller and action without a model?

I have several models: Email Letter Call All three belong to a model Campaign. And a Campaign has_many Contacts I envision being able to see a schedule for Today by going to domain/schedule/today What I'd like it to do would be to show all the Events (Email, Letter, Call) that have to happen today for each campaign. I tried the f...

Java: how to have try-catch as conditional in for-loop?

I know how to solve the problem by comparing size to an upper bound but I want a conditional that look for an exception. If an exception occur in conditinal, I want to exit. import java.io.*; import java.util.*; public class conditionalTest{ public static void main(String[] args){ Stack<Integer> numbs=new Stack...

How to get the previous value from incrementing variable in for loop?

In My last post I asked : How to create dynamic incrementing variable using "for" loop in php? like wise: $track_1,$track_2,$track_3,$track_4..... so on.... whose answer I selected as for($i = 0; $i < 10; $i++) { $name = "track_$i"; $$name = 'hello'; } and for($i = 0; $i < 10; $i++) { ${'track_' . $i} = 'val' } Now, What ...

How to get the next row from the Database table?

How to get the next row from the Database table? Such that the row might be incremented row that is if structure has a field called "id" then the row can be id++ or very next incremented row, but it may also b any other id containing row (NOT VERY NEXT) , (because the ids could be deleted from the table). I am using Mysql Database below...

Need to convert this for loop to a while loop

Hi guys, I solved a problem recently. But I have this one piece of code where I dont utilize the for loop initialization and condition check. It looks a bit odd that way for a for loop. I want to convert it into a while loop. Please help me do it. I tried many times, but somewhere something is missing. for(;;current =(current+1)%n){ ...