loops

How do I change the address of a New struct in a loop?!

I'm writing a simple program which is about polynomials using linked lists in C#. The problem I have is that whenever it creates a new struct (node) in the for loop it gives it the same address as the previous node was given. How do I fix that? Here is my struct: struct poly { public int coef; public int pow; public poly* link;} ; An...

C++/boost generator module, feedback/critic please

hello. I wrote this generator, and I think to submit to boost people. Can you give me some feedback about it? It basically allows to collapse multidimensional loops to flat multi-index queue. Loop can be boost lambda expressions. Main reason for doing this is to make parallel loops easier and separate algorithm from controlling struct...

why does an infinite loop trash the CPU?

I know an infinite loop creates a CPU problem. But, I don't quite understand why. Can anyone explain that to me. Thanks! ...

Loop through a Map with JSTL

I'm looking to have JSTL loop through a Map and output the value of the key and it's value. For example I have a Map which can have any number of entries, i'd like to loop through this map using JSTL and output both the key and it's value. I know how to access the value using the key, ${myMap['keystring']}, but how do I access the key?...

never ending loop : fatal error

my code- function create_id() { //global $myusername; $part1 = substr("Piyush", 0, -4); $part2 = rand (99,99999); $part3 = date("s"); return $part1.$part2.$part3; } echo create_id(); //this is printing fine. function isUniqueUserID($userIDToCheck) { $sqlcheck = "Select * FROM ruser WHERE userId...

Rails each loop insert tag every 6 items?

Hello Stack Anon, I have X number of image objects that I need to loop through in a view and want to create a new div every 6 objects or so (for a gallery). I have looked at cycle but it seems to change every other record. Does anyone know of a way to insert code into a view every 6 times? I could probably do it with nested loops but ...

Drupal and Login Toboggan -- infinite redirect loop

I'm getting a redirect loop when using Login Toboggan. It doesn't happen all of the time and I think I've narrowed it down to something with the session, specifically the active-tabs[last-active-href] value. Since it's intermittent, I was able to print out a session of a working copy and a non-working copy. Here are both: WORKS -- Arr...

Help with a loop to return UIImage from possible matches

I am parsing a list of locations and would like to return a UIImage with a flag based on these locations. I have a string with the location. This can be many different locations and I would like to search this string for possible matches in an NSArray, and when there's a match, it should find the appropriate filename in an NSDictionary....

JQuery going through a set of UL and dynamically set ids incremently on each one

I have an unordered list which contains serveral items called 'oListItems' the UL has a class but no id. The class OuteroListItems contains many of oListitems oList.AppendFormat("<ul class='OuteroListItems'>"); oList.AppendFormat("<li>"); oList.AppendFormat("<ul class='oListItems'>"); oList.Appen...

for (Object object : list) [java] and index element

Is there a way to get an element id of a list to get it later through list.get(index) when using for(Object obj: o) construction Only define a local var and manually incrementing it? Anything simpler? ...

How can I loop through each of the days of a given week in Ruby?

I am defining monday and friday using the following: @monday = Date.today.at_beginning_of_week @friday = 5.days.since(@monday) But I actually need, for any given day, to loop through Monday, Tuesday, Wednesday and take that date and put the output into a column. <th>Monday</th> <th>Tuesday</th> etcetera A given row, for example, ...

Skipping the BufferedReader readLine() method in java

Is there a easy way to skip the readLine() method in java if it takes longer than, say, 2 seconds? Here's the context in which I'm asking this question: public void run() { boolean looping = true; while(looping) { for(int x = 0; x<clientList.size(); x++) { try { Comm s = clientList.get(x); ...

Creating a for loop in R

For this project you are required to use an R script to simulate the effectiveness of the t-test. A for loop will be used to carry out the following 2000 times: Would the loop look something like this i <- 1 for (i <= 2001) { x <-rf(5,df1=5,df2=10) b <- df2 p.value <-t.test(x,mu=(b/(b-2))$p.value i <- i+1 } ...

PHP: Display comma after each element except the last. Using 'for' statement and no 'implode/explode'

I have this simple for loop to echo an array: for ($i = 0; $i < count($director); $i++) { echo '<a href="person.php?id='.$director[$i]["id"].'">'.$director[$i]["name"].'</a>'; } The problem here is that when more than one element is in the array then I get everything echoed without any space between. I want to separate each element...

FLVPlayback component won't seamlessly loop

Everything I've tried so far with a FLVPlayback component to seemlessly loop a progressively-downloaded 15 second video has failed. There's always a split-second pause when it's time to loop. For the scenario, embedding video in a flash project is not an option, and the split-second pause is unacceptable. I've tried setting autorewind...

Introduction to vectorizing in MATLAB - any good tutorials?

I'm looking for any good tutorials on vectorizing (loops) in MATLAB. I have quite simple algorithm, but it uses two for loops. I know that it should be simple to vectorize it and I would like to learn how to do it instead of asking you for the solution. But to let you know what problem I have, so you would be able to suggest best tuto...

User authentication using CodeIgniter

I have a problem creating authentication part for my application. Below is the simplified version of my controllers. The idea is that the MY_controller checks if session with user data exists. If it doesn’t, then redirects to the index page where you have to log in. MY_controller.php class MY_Controller extends Controller { function...

ColdFusion, HowTo Convert a String to an Array?

Given the following string in ColdFusion: ul[0][id]=main1 &ul[0][children][0][id]=child2 &ul[0][children][0][class]= &ul[1][id]=main3 &ul[2][id]=main4 &ul[3][id]=main5 How can I create an array with the info above? Thanks ...

Javascript function question

I searched but couldn't find an answer to this seemingly easy question, so... Suppose I have a loop in which I need to set callbacks. My callback function looks like this: function callback(var1) { // code } Now my loop is something like this: for( //condition) { var x = something_different_each_time; document.getElementById('fo...

How can I loop through variables in SPSS? I want to avoid code duplication.

Is there a "native" SPSS way to loop through some variable names? All I want to do is take a list of variables (that I define) and run the same procedure for them: pseudo-code - not really a good example, but gets the point across... for i in varlist['a','b','c'] do FREQUENCIES VARIABLES=varlist[i] / ORDER=ANALYSIS. end I've notic...