Hi there, a quick, simple question from me about for-loops.
Situation
I'm currently writing some high-performance code when I suddenly was wondering how the for-loop actually behaves. I know I've stumbled across this before, but can't for the life of me find this info again :/
Still, my main concern was with the limiter. Say we have:
...
How can I write this code in T-SQL?
var categories = new []{ "cat1", "another category", "one more" };
for (var i = 0; i<categories.count; i++)
{
insert into Categories (id, name)
values (i, categories[i])
}
Is it possible?
...
Why is the following line producing errors?
for(int i = 0, int pos = 0, int next_pos = 0; i < 3; i++, pos = next_pos + 1) {
// …
}
error: expected unqualified-id before ‘int’
error: ‘pos’ was not declared in this scope
error: ‘next_pos’ was not declared in this scope
Compiler is g++.
...
I have a simple for loop with the following code
For i As Integer = 0 To 4
Snake(i).X = (120 - 20 * i)
Snake(i).Y = 120
SnakeBody(i).Location = New Point(Snake(i).X, Snake(i).Y)
Snake(i).Facing = 3
Next i
But for some reason I unable to debug it. I place a breakpoint on the line...
I am trying to utilize Google's AJAX Language API to translate each value in an array.
for(var n=0; n < mytext.length; n++) {
google.language.translate(mytext[n], originalLanguage, newLanguage, function(result){
if(!result.error){
document.getElementById("caption") += mytext[n]+" has been translated to "+result.translation;
}
...
hai can any one help me where can i get a sample code for editing pdf files in iphone
...
This loop takes forever to run as the amount of items in the loop approach anything close to and over 1,000, close to like 10 minutes. This needs to run fast for amounts all the way up to like 30-40 thousand.
'Add all Loan Record Lines
Dim loans As List(Of String) = lar.CreateLoanLines()
Dim last As Integer = loans.Count - 1
For i = 0 T...
Well i have a simple for loop function issue is that i want the page to reload once done but
what happens sometimes is that the page preloads before the loop has been fully run which makes the script not behave properly
it's like this at the moment:
for (loop condition) {
action
}
window.location.reload();
but as i just mention...
Hello, I have a Dictionary of Classes where the classes hold attributes that are lists of strings.
I made this function to find out the max number of items are in one of those lists for a particular person.
def find_max_var_amt(some_person) #pass in a patient id number, get back their max number of variables for a type of variable
...
It's a pretty simple question, I always have to go check here and then I hit my head and say it's so obvious. But really after a week of not using it I usually end up writing
for ($i = 1; $i++; $i <= 10;) {
echo $i;
}
some Mnemonic might help
...
Possible Duplicate:
When implementing an infinite loop, is there a difference in using while(1) vs for(;;) vs goto (in C)?
In languages where while (true) or for (;;) both mean "loop forever", which should I use?
...
First of all, I understand in 90% of applications the performance difference is completely irrelevant, but I just need to know which is the faster construct. That and...
The information currently available on them on the net is confusing. A lot of people say foreach is bad, but technically it should be faster since it's suppose to simpl...
Given the following code:
var tmp = [0];
for(var i=0;i<100;i++) {
tmp[0] = i;
console.log(tmp);
}
I'd expect output of [0], [1], [2], [3], etc
But I instead get [99], [99], [99], [99], etc
Stepping through the code in a debugger (firebug) however nets me the correct result of [0], [1], [2].
...
I am trying to create a batch script for my Windows machine that loops through a list of (string/decimal) values and uses each value as a parameter inside the loop.
Below is an example of a simple for loop I would like to use to display all the different version files (from my list)
FOR ? in ('1.1','1.2','2.4','3.9') do echo V[value_fr...
I'm starting to learn perl, using the Wrox Beginning Perl available on perl.org and have a question regarding a for loop example they provide in Chapter 3.
#!/usr/bin/perl
use warnings;
use strict;
my @count = (1..10);
for (reverse(@count)) {
print "$_...\n";
sleep 1;
}
print "Blast Off!\n"
This is the script they pr...
Hi, on a website i want to do this: (simplified)
myHandlers = new Array();
for(var i = 0; i < 7; i++) {
myHandlers.push(new Handler({
handlerName: 'myHandler'+i, // works, e.g. ->myHandler1, 2, 3 etc.
handlerFunc: function(bla) { /*...*/ alert(i); } // doesn't work,all return 7
}
}
I could set the counter as another attrib...
I have this loop, its purpose is to loop through a range of dates and perform some logic to automate adding entries into the database. The issue is that the incrementing portion, date.AddDays(1.0) isn't working, and is always the same result, causing an infinite loop. Any insight?
for (DateTime date = DateTime.Now; futureDate.Compare...
Possible Duplicate:
Help with C puzzle
The intention of the program was to print a minus sign 20 times, but it doesn't work.
#include <stdio.h>
int main()
{
int i;
int n = 20;
for( i = 0; i < n; i-- )
printf("-");
return 0;
}
...
I am trying to sum all the numbers up to a range, with all the numbers up to the same range.
I am using python:
limit = 10
sums = []
for x in range(1,limit+1):
for y in range(1,limit+1):
sums.append(x+y)
This works just fine, however, because of the nested loops, if the limit is too big it will take a lot of time to compu...
Does it make any difference if I use e.g. short or char type of variable instead of int as a for-loop initializer?
for (int i = 0; i < 10; ++i) {}
for (short i = 0; i < 10; ++i) {}
for (char i = 0; i < 10; ++i) {}
Or maybe there is no difference? Maybe I make the things even worse and efficiency decreases? Does using different type ...