473,799 Members | 3,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

2 iterations - different results - why?

Hello,

Can anyone tell me why these 2 sets of code give different results?

for (J in Next) {
<action>
}
<function>
for (J=0;J<Next.len gth;++J) {
<same action as above>
}
<same function as above>

I would like to change the second version so that it gives the same
results as the first one.

Any ideas please?!

Cheers

Geoff

Jun 27 '08
10 1238
On Sun, 20 Apr 2008 01:46:35 +0200, Joost Diepenmaat <jo***@zeekat.n l>
wrote:

Joost,

OK now!

I have used the vanilla iteration and prototype.js is OK. My solution
is not very elegant I expect but it works ... I added 2 extra items to
Arry etc. The problem was not with the vanilla iteration as you
supsected but other parts of the code.

Thanks for your help.

Cheers

Geoff

var Arry = [
/* State 0 : */ [1,2],
/* State 1 : */ [3],
/* State 2 : */ [3],
/* State 3 : */ [4,5],
/* State 4 : */ [6],
/* State 5 : */ [6],
/* State 6 : */ [7,8],
/* State 7 : */ [9],
/* State 8 : */ [9],
/* State 9 : */ [10,11],
/* State 10 : */ [12],
/* State 11 : */ [12] ]

var result =new Array();
var test_num=1;
function A(f)
{
soundManager.pl ay('mySound'+te st_num ,'../assets/audio-group1/Track' +
(+test_num + 22) + '.mp3');
}
function B(f)
{
result[test_num] = "same";
test_num++;
}

function C(f)
{
result[test_num] = "different" ;
test_num++;
}

function D(f) {
alert('finished ');
}

DoSpecificTask = [A, B, C, A, B, C, A, B, C, A, B, C ]

function Fn(Arg) {
var F = Arg.form, State, J, Next;
State = Arg.name.substr ing(1,3);
for (J=0 ; J<12 ; J++) F["B"+J].disabled = true; // clear all
Next = Arry[State];

for (var J = 0; J < Next.length; ++J) {
F["B"+Next[J]].disabled = false;
}
if ( (State == 10) || (State == 11) ) {
DoSpecificTask[State](F);
sendGroup1Lab5( );
} else {
//alert(State);
DoSpecificTask[State](F);
}

}
Jun 27 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1980
by: Infiniti | last post by:
Lets say I have an xml file as such <page> <chapter> <paragraph/> <paragraph/> <paragraph/> <paragraph/> <paragraph/> </chapter>
18
3715
by: Derek Basch | last post by:
What is the best way to count nested loop iterations? I can only figure to use an index but that seems kludgy. index = 0 for animal in zoo: for color in animal: index += 1 Thanks, Derek Basch
22
26747
by: silversurfer2025 | last post by:
Hello everybdy, I am a little confused for the following reason: In my code I used a simple for-loop in order to initialize a 2D-array of floats to zero. Because of efficiency reasons, I changed it to use memset and I get totally different results.. How can this be? Here is the example: float gaborfilter;
3
3647
by: Bill Hutchison | last post by:
I have a query that returns different results (3508 rows for snapshot, 6288 for dynaset) and that is the only thing I change to get the different results. When I try to make a table from the query, it makes 3508 rows. I also know that there are 6288 unique rows in the results. Is there some configuration choice that is causing the snapshot version to return the wrong row count? Thanks for your help on this one. If it wasn't that the...
16
1091
by: James Stroud | last post by:
Hello all, I was staring at a segment of code that looked like this today: for something in stuff: whatever(something) and was wondering if the compiler really made a copy of the slice from stuff as the code seems to suggest, or does it find some way to produce an iterator without the need to make a copy (if stuff is a built-in
6
1944
by: Avi | last post by:
I need to implement the following calculation: f = (a*b) + (c*d) where a,b,c,d are given double values and f is a double variable for the result I found out that using two different implementations gives two different results: 1) In the first implementation I compute the entire equation in memory 2) In the second implementation I store intermediate to variables, and then load them to compute the final result.
87
3757
by: pereges | last post by:
I have a C program which I created on Windows machine. I have compiled and executed the program on windows machine and it gives me the consistent output every time i run it. for eg. input a = 2, b =3 lets say a sum operation is to be performed, then: output: 5
0
1106
by: John [H2O] | last post by:
I can try, would you mind giving very brief instructions on how to 'run it under gdb'... thanks! I'll post results over at numpy-discussions. Robert Kern-2 wrote: -- View this message in context: http://www.nabble.com/f2py-Error---module-crashes-after-several-iterations...-tp20128015p20131768.html
5
2545
by: Christopher Brewster | last post by:
I am running the same script on the same data on two different machines (the folder is synchronised with Dropbox). I get two different results. All the script does is count words in different files and perform a simple set operation on the word lists. The laptop is a Macbook Pro (2 1/2 years old) running OS X 10.5.5 with Python 2.5.1 The desktop is an iMac (brand new) running OS X 10.5.5 also with Python 2.5.1 I have tried running the...
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10484
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10228
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.