loops

What am I doing wrong? (Simple Assembly Loop)

It won't let me post the picture. Btw, Someone from Reddit.programming sent me over here. So thanks! TITLE MASM Template ; Description ; ; Revision date: INCLUDE Irvine32.inc .data myArray BYTE 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 .code main PROC call Clrscr mov esi, OFFSET myArray mov ecx, LENGTHOF myArray mov e...

Javascript pause problem in a loop, ajax, jquery

Hi I'm trying to create a simple animation. Long story short, I've got a list of 20 small divs and one outside div. I want to display five small divs within a large div at the time. Ideally, I would get a set of next 5 divs every 5 seconds. I'm using jquery ajax function to create small divs, here's the code: $(document).ready(function...

¿How to bind params to an statement using a loop?

Hi! I'm just learning to use PDO, and I want to bind params to a delete statement using a loop. I'm using a code like this that definitely doesn't works: public function delete_user ($post, $table='mytable') { $delete = $this->conn->prepare("DELETE FROM $table WHERE id IN (:id) "); ...

Closures in a for loop

Closures in a loop are causing me problems. I think I have to make another function that returns a function to solve the problem, but I can't get it to work with my jQuery code. Here is the basic problem in a simplified form: function foo(val) { alert(val); } for (var i = 0; i < 3; i++) { $('#button'+i).click(function(){ foo(i...

Looping through a dataset and handling missing values

I am looping through a big data file and like to detect the type of variable in each column, eg if it is an Intenger or a Float etc. It works perfectly fine, however, at the moment it is still very basic and I like to add another idea. So far the declaration of the variable is based on the second row of the data set. (The first one is us...

AS3 Functions: is it possible to return a value inside of a loop?

I am trying to find the index from an array using a loop function, but I am getting an error: private function findMatch(matchValue:int):int { for (var i:int = 0; i < playersList.length; i++) { if (playersList[i].value + matchValue == levelTarget) { return i; } ...

C#: Cannot assign to foreach iteration variable

I'm trying to condense this by wrapping it in a loop: if (pos.X + pixelRadius < 0) { pos.X = bounds.Width - pixelRadius; } else if (pos.X + pixelRadius > bounds.Width) { pos.X = pixelRadius; } if (pos.Y + pixelRadius < 0) { pos.Y = bounds.Heigh - pixelRadius; } ...

Quick Java LinkedList problem

Basically I'm rather new to Java and I have a problem with understanding a line and getting it to work. Heres the line of code: LinkedList<ClientWorkers> clients = SingletonClients.getClients(); Heres the procedure its in: ClientWorker(Socket client, JTextArea textArea) { this.client = client; this.textArea = textAre...

Merge several data.frames into one data.frame with a loop

I am trying to merge several data.frames into one data.frame. Since I have a whole list of files I am trying to do it with a loop structure. So far the loop approach works fine. However, it looks pretty inefficient and I am wondering if there is a faster and easier approach. Here is the scenario: I have a directory with several .csv fi...

How do I make a loop in assembly language?

I have written the code so far as: .code main Clrscr mov dh,10 ;row 10 mov dl,20 ;column 20 call Gotoxy ;locate cursor PromptForIntegers WriteString ;display string ReadInt ;input integer ArraySum WriteString ;display string WriteInt ;displ...

Why do the following snippets (one using "while" the other using "for") have different behaviors?

I have been trying out some basic exercises involving loops. Can someone tell me why the following snippets have different outputs? While Loop while (i<3) { while(j<3) { printf("(%d %d) ",i,j); j++; } i++; } Output (0 0) (0 1) (0 2) For Loop for(i=0;i<3;i++) { for(j=0;j<3;j++) ...

Redirection loop problem at facebook iframe application

I do IFrame application for facebook. Problem is: any link inside it causes redirect loop Link is: http://mydomain/mypage?fb_sig=[what I got from $_GET['fb_sig']] (to test I link to the same page as my loaded canvas is loaded from) when I click on it, my server returns: <script type="text/javascript"> top.location.href = "http://www...

Starting a thread for each inner loop in OpenMP

I'm fairly new to OpenMP and I'm trying to start an individual thread to process each item in a 2D array. So essentially, this: for (i = 0; i < dimension; i++) { for (int j = 0; j < dimension; j++) { a[i][j] = b[i][j] + c[i][j]; What I'm doing is this: #pragma omp parallel for shared(a,b,c) private(i,j) reduction(+:diff)...

Two Counts for the for loop?

Can you have two counts with for loop? Example: for( var count1 = 0, count2 = 0; count1 < 5; count1++, count2++ ) { } If not, what would be a good way to handle two separate counts other than using two loops? ...

In loops, does this matter?

A while( x < 100 ) { if( x == 1 ) { echo "Hello World!" } else { echo "Bottles" } x++; } B while( x < 100 ) { if( x != 1 ) { echo "Bottles" } else { echo "Hello World!"} x++; } Would it really make a difference when having such a big loop? ...

Ruby on Rails Nesting Blocks

Hi I have a block that I need to nest another block in. Or maybe I don't and I am doing this totally wrong. There is a UNIT and the UNIT has_many COMPANIES Then COMPANIES has_many USERS on the UNIT show page I am trying to do something like this: <% @company.each do |c|%> <%= c.name %> <% ??? each do |f| %> <p> Name: <%= f....

How to make a bash script that creates 40 simultaneous instances of a program?

I am new to bash and Linux. I have a program I have written that I want to create multiple simultaneous instances of. Right now, I do this by opening up 10 new terminals, and then running the program 10 times (the command I run is php /home/calculatedata.php What is the simplest way to do this using a bash script? Also, I need to know ...

jQuery looping my fadeIn/fadeOut

I've done some easy .hover(function() statement in jQuery. When i hover over a text i simply want a #div.fadeIn, and on non-hover fadeOut. It works. But it's just if i spam the text-trigger with hover and un-hoverring really quickly and then stop the animation begin to give a blinking effect. It just kind of loops, really annoying! ...

C# float infinite loop

The following code in C# (.Net 3.5 SP1) is an infinite loop on my machine: for (float i = 0; i < float.MaxValue; i++) ; It reached the number 16777216.0 and 16777216.0 + 1 is evaluates to 16777216.0. Yet at this point: i + 1 != i. This is some craziness. I realize there is some inaccuracy in how floating point numbers are stored. ...

PHP Optimize Function in Loop

I am micro-optimizing this function and have a bit of a problem where inside a loop I am checking if a value outside of the loop is 0, if so call function and similarly in the function it calls. How would I refactor it so there is no conditional logic (which is slow) inside these loops. foreach($this->layer[$l]->objs as $obj) { //H...