loops

iPhone/iPad - Loop Background Music?

Hi First time doing this, hope you can help. What the best way of playing background music for my iPad game? 1b. How do I do this? Whats the best format of having that music file in for playback? Will this this song happily play through the entire game, no interruptions when changing view? How can I loop this music? Thanks. ...

javascript/jquery loop works, but only in reverse

I am writing a task checklist using javascript and jquery for my work. What happens is the page uses AJAX to fetch data from various tables and put them all together. That part works fine. The problems start to arise when the program tries to append the data to the numbered DIVs. The function I have takes in two arrays, one for the ids...

C++: scope of for loop?

#include <iostream> using namespace std; int main() { int i; for(i=0; i <= 11; i+=3) cout << i; cout << endl << i << endl; } output is: 0 3 6 and 9 and then once it exits the loop its 12. The addresses of i inside the loop and out appear the same What I need to know is: Is the i inside the for loop the same as the...

ParallelFor code for finding sum of few elements in an array (Subsetsum problem)

I have the following C# code fragment: using System; class count { public static void Main() { int [] a = {-30, 30, -20, -10, 40, 0, 10, 5}; int i,j,k; int N=8; for (i=0; i < N; ++i) for (j=i+1; j < N; ++j) for (k=j+1; k < N; ++k) if (a[i] + a[j] + a[k] == 30) Console.WriteLine (a[i].ToString () + a[j].ToSt...

passing while() array to a variable out of while() in php

suppose i have a query $array = array(); $sql = mysql_query("SELECT * FROM table"); while($row=mysql_fetch_array($sql)){ $data = $row['data']; } $array = $data; Now how can i get that each $data values out of while in an array() i.e $array ...

Simple for loop not working.

I've just started learning programming. I'm studying for loops but this program does not work as expected. I want to break the loop when $a is equal to 3 so that I get the output 1 2 but I get 3 as output :( for($a=0;$a<10;++$a) { if($a==3) break print"$a "; } Please help. ...

how to make jquery each a number .

This is my code: $.each(3, function(n) { alert(n); }); I want to alert three times but it doesn't work. What can I do? ...

how to multiply integers to values in an array?

Actually I wanted to get absolute values out of an array and the only way i can think of multiplying the values in the array with (-1) using 'if' loop. But does it work like that? as in: for (i = 1 ; i <= 10 ; i++) { if(x[i]<1) { x[i] = (-1) * x[i]; } else{} ratio[i] = (x[i]/fx[i]) * 0.5; } I am not sure if u can...

Redundant loop inside a process (VHDL)?

Hello, I'm taking a university course to learn digital design using VHDL, and was doing some reading in the book the other day where I came across the following piece of code: architecture abstract of computer_system is ... cpu : process is variable instr_reg : word; variable PC : natural; ... begin...

Python - Way to distinguish between item index in a list and item's contents in a FOR loop?

For instance, if I wanted to cycle through a list and perform some operation on all but the final list entry, I could do this: z = [1,2,3,4,2] for item in z: if item != z[-1]: print z.index(item) But instead of getting the output "...0 1 2 3," I'd get "...0 2 3." Is there a way to perform an operation on all but t...

this line is overwriting the array

ok so i am creating a multidementional array and this line only allows one element into it. How do i check to see if $related[$row_r['Category_name']][$row_r['name']] is greater then 0 and if so dont overwrite the value and just append onto it while($row_r = mysql_fetch_assoc($result)){ $related[$row_r['Category_name']][$row_r['na...

Get 0 to 9999 in PHP using FOR EACH and Array?

How would I print all values 0...9999 using an array of $array = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); ? No clue, please help. ...

rails handling single and multiple returned objects

In rails you can use .each do || to loop through the returned results of a query. But what if only one line is returned? or you have the possibility of 0, 1, or many? how do you handle these scenarios without throwing an error? This situation in particular is one where i am accepting nested attributes following ryan's railcast blog (htt...

using PHP.scandir() to scan files and then require_once them

hi again every one this is my third question so far on stackoverflow :D i am defining files and their location on my first_run.php files, the files that i define here is those files containing classes, helper functions and any other files required at early development, this first_run.php contains only a few lines of codes but the line ...

how to multiply integer or double with values in an array?

The title says it all actually. In a simple way, i have an array of 10 values for example..and i would like to multiply each value with 5. Can i actually just do the following? for (i = 0 ; i <10 ; i++) { x[i]=x[i]*5; } And what about getting square for values in the array and be stored back into the same array? As in I want x[...

Chat server design of the "main" loop

Hey, I am writing on a small tcp chat server, but I am encountering some problems I can´t figure out how to solve "elegantly". Below is the code for my main loop: it does: 1.Initiates a vector with the basic event, which is flagged, when a new tcp connection is made. 2. gets this connection and pushes it back into a vector, too. Then w...

seamless dynamic audio loop on iPhone

Ok, So I am trying to seamlessly loop together three sound files with the second file being looped against itself n times. Let's assume I can get them to loop seemlessly together in another program by butting them together. however when I use audioPlayerDidFinishPlaying delegate method of avaudioplayer there is a slight delay in the but...

How to use threads to replace looping a subroutine in perl/pdl

I have a perfectly good perl subroutine written as part of a perl module. Without going into too many details, it takes a string and a short list as arguments (often taken from terminal) and spits out a value (right now, always a floating point, but this may not always be the case.) Right now, the list portion of my argument takes two v...

C program to merge files not finding EOF, stuck in infinite loop!

I'm having some problems trying to run this program I am working on...The requirements say I was not allowed to use a sort function...I had do something myself....etc. Pretty much, the program compiles but hangs after executed...I'm guessing it's stuck in an infinite loop...but I can't seem to find it... :( This program reads to data f...

Remove duplicates from a large integer array using Java

Hello all! Do you know of any time efficient way to remove duplicated values from a very big integer array using Java? The size of the array depends on the logged in user, but will always exceed 1500000 unsorted values with some duplicates. Every integer contains a number between 100000 and 9999999. I tried converting it to a List, but...