Hi,
i'd just like to get some thoughts on the best way to do for loops (in c based languages).
all over the web code samples have for loops which look like this
for(int i = 0; i < 5; i++)
while i used the following format
for(int i = 0; i != 5; ++i)
i do this because i believe it to be more efficent but does this really matter in m...
Hello
Here is what I want, inside the BACKUPDIR, I want to execute cscript /nologo c:\deletefile.vbs %BACKUPDIR% until number of files inside the folder is greater than 21(countfiles holds it).
Here is my code:
@echo off
SET BACKUPDIR=C:\test
for /f %%x in ('dir %BACKUPDIR% /b ^| find /v /c "::"') do set countfiles=%%x
for %countfiles%...
I am a php programmer trying to understand python's for in syntax
I get the basic for in
for i in range(0,5):
in php would be
for ($i = 0; $i < 5; $i++){
but what does this do
for x, y in z:
and what would be the translation to php?
This is the full code i am translating to php:
def preProcess(self):
""" plan for the arra...
I don't think I need to explain exactly what the code does. The point is that while performing the chisq.test outside the loop, I get a result like this (expected):
Chi-squared test for given probabilities
data: observed
X-squared = 185912, df = 5, p-value < 2.2e-16
but when I try to do the test in a loop, the expected resu...
I am learning hygiene and I tried to make a simple for loop in Scheme. I want to support three kinds of constructs as shown in example below
(for i = 1 : (< i 4) : (++ i)
(printf "Multiplication Table for ~s\n" i)
(for j = 1 to 5
(printf "~s * ~s = ~s\n" i j (* i j))))
I want to also support for loops with filters like this:...
Hi. I'm quite new to bash scripting and usually avoid it all costs but I need to write a bash script to execute some simple things on a remote cluster. I'm having problems with a for loop that does the following:
for i in {1..20}
do
for j in {1..20}
do
echo (i*i + j*j ) **.5 <--- Pseudo code!
done
done
Can you hel...
which one is the fastest for iterating through arrays in php? or does another exist which is also faster for iterating through arrays?
...
So I am trying to make a parameterized type that will work for anytype in Java this includes anything that is an object, and also the primitives types. How would i go about doing this?
Ok, suppose I want the target of a for-each to be a primitive, so its
for(int i : MyClass)
something like that. Is this possible to do?
...
Is there a Ruby version of for-loop similar to the one in Java/C(++)?
In Java:
for (int i=0; i<1000; i++) {
// do stuff
}
The reason is because I need to do different operations based on the index of the iteration. Looks like Ruby only has a for-each loop?
Am I correct?
...
Like :
var result = eval('(' + response + ')');
var html = value = '';
for(item in result)
{
}
response is a json response.
It stops at for.. in IE8.
How to fix that?
EDIT
I got the same error when running:
result = [1,2,3];
for(item in result)
{
...
}
...
Is there any performance testing results available in comparing traditional for loop vs Iterator while traversing a ArrayList,HashMap and other collections?
Or simply why should I use Iterator over for loop or vice versa?
...
Ok I've been asking alot of JS questions lately, and realized I just need to go learn it.
Been following tutorials at http://www.tizag.com/javascriptT very simple and straightforward.
I just want to make sure I understand this correctly. It took me a while to get it:
<script type="text/javascript">
var myString = "zero one two three f...
I am making a Javascript game with the canvas tag, and I am using an enhanced for loop to update the player positions.
In brief:
var actors = new Array();
var player = new Actor(0, 0, img);
actors[0] = player;
function update_positions() {
//position 1
for(var a in actors) {
//position2
a.xpos += a.xvel;
...
With MSSQL, I can mix in case, if...then, and while constructs in my SQL code. Is anything similar available for SQLite? I have not seen anything on "mixing procedurally" with SQLite, anywhere.
Thanks.
...
This is to do with the following code, which uses a for loop to generate a series of random offsets for use elsewhere in the program.
The index of this for loop is unused, and this is resulting in the 'offending' code being highlighted as a warning by Eclipse / PyDev
def RandomSample(count):
pattern = []
for i in range(coun...
How does one generate a set of lists that incorporate the index from a for loop in the list name:
for j in range(10):
li"j" = []
How can the index 'j' be part of the name, so the lists are li0, li1, li2, ...
Thanks!
...
I got this code:
<script>window.onload = function () {
var container, i;
for (i = 0; i < 10; i ++) {
container = document.createElement ("div");
container.innerHTML = i;
container.style.border = "1px solid black";
container.style.padding = "10px";
container.onclick = function () {
alert (i);
}
document.body....
Python's iterators are great and all, but sometimes I really do want a C-style for loop - not a foreach loop. For example, I have a start date and an end date and I want to do something for every day in that range. I can do this with a while loop, of course:
current = start
while current <= finish:
do_stuff(current)
...
Hi,
I am having trouble with the following command prompt commands (in Windows XP).
set SOMEVAR=
for /F %i in (1 2 3) do set SOMEVAR=%SOMEVAR% "%i"
echo %SOMEVAR%
I expect it to build the SOMEVAR variable so that it contains each item in the for loop in quotes, separated by a space: 1 2 3
However what this is what I get...
Hi all,
On a mailing list I'm subscribed to, two fairly knowledgeable (IMO) programmers were discussing some optimized code, and saying something along the lines of:
"On the CPUs released 5-8 years ago, it was slightly faster to iterate for loops backwards (e.g. for (int i=x-1; i>=0; i--) {...}) because comparing i to zero is more effi...