2
голосов
4ответов
22208 просмотров

creating dynamic Arrays Javascript

Hello i want to create a array in java script withing 2 for loops var i; var a; var total = document.getElementsByName('qm[7]') var creativity = document.getElementsByName('qm[0]'); var design = document.getElementsByName('qm[1]'); var text = document.ge...

0
голосов
3ответов
294 просмотров

why does this javascript array for loop not work like the literal version?

I'm new to javascript and was trying to refactor some code, clearly there's something I'm missing in javascript that I'd like to learn. This code produces a value once all 5 list boxes have something selected: function GetTotal() { //_listSeverity = document.getElementById("_listSeverity...

1
голосов
1ответов
1128 просмотров

Refactoring JSP scriptlet loop to be more readable

I have some JSP code, which writes a tree representing hierachical data. This data is represented using nested layers. In the JSP code there are many code snippets similar to the following code (which outputs as many closing div tags as is the numerical value of variable differenceAmount): &lt...

1
голосов
1ответов
1406 просмотров

XSLT: Use result of expression inside a loop outside of that loop

I'm trying to transform certain parts of an XML file to another XML file. The source file: <CUSTOMERS> <CUSTOMER> <CUSTOMER_NUMBER>12345678</CUSTOMER_NUMBER> <CUSTOMER_ADDRESS> <CUSTOMER_ADDRESS_NAME>John Doe</CUSTOMER_ADDRESS_NAME> ...

0
голосов
2ответов
455 просмотров

building first custom CMS and have been told to use Dreamweaver and a plug in called Horizontal Looper

so I'm in a little over my head right now and want to verify that i've been given good advice as for how to build this simple CMS site. It's a book site and there's going to be a few image galleries (for example, one for characters) where the user clicks different thumbnails and a span with text ...

59
голосов
5ответов
48184 просмотров

Iterating over arbitrary dimension of numpy.array

Is there function to get an iterator over an arbitrary dimension of a numpy array? Iterating over the first dimension is easy... In [63]: c = numpy.arange(24).reshape(2,3,4) In [64]: for r in c : ....: print r ....: [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] [[12 13 14 15] [16 1...

3
голосов
5ответов
658 просмотров

Developing Games - How are things that take more than one game loop performed?

I'm using C#, but this is applicable to developing a game in any language. Most games use a 'game loop', which would look something like this: while (game is running) { UpdateEnvironment(); DrawEnvironment(); } I'm struggling to understand how things which would take more than one game lo...

1
голосов
3ответов
3918 просмотров

Converting an input word number (like seven) into a character (like @)

so if the user types down seven with Scanner, @@@@@@@ (7) will be the output. I'll have to use a for loop statement but I can at least figure out that much. Just need help with figuring out a way to convert word numbers into a numerical number and finally into a random character.

7
голосов
3ответов
2994 просмотров

Passing values to onclick

If I create a whole lot of HTML elements using a loop, like for (i= 1; i < 100; i++) { var my_element = document.createElement ("td"); row.appendChild (my_element); my_element.onclick = function () {my_function (i)); } then when the element is clicked, the value of i passed to m...

466
голосов
27ответов
389423 просмотров

How to remove elements from a generic list while iterating over it?

I am looking for a better pattern for working with a list of elements which each need processed and then depending on the outcome are removed from the list. You can't use .Remove(element) inside a foreach (var element in X) (because it results in Collection was modified; enumeration operation m...

1
голосов
5ответов
6297 просмотров

How to loop through all rows in an Oracle table?

I have a table with ~30,000,000 rows that I need to iterate through, manipulate the data for each row individually, then save the data from the row to file on a local drive. What is the most efficient way to loop through all the rows in the table using SQL for Oracle? I've been googling but can...

2
голосов
5ответов
571 просмотров

JavaScript Variable Scope

I'm having a problem with some JavaScript code. Script setTimeout(function() { for (var i = 0; i < 5; i++) { setTimeout(function() { console.log(i); }, i * 200); } }, 200); Outputs 5, 5, 5, 5, 5 instead of 1, 2, 3, 4, 5 I can kind of understand why thi...

6
голосов
5ответов
20032 просмотров

Looping through XML with jQuery

I've got some basic code that can loop through some XML that's generated from Adobe RoboHelp (for our help documentation). This works fine, but since a topic could be nested as many time as the writer wants, i need a better way to loop through this XML rather than just nesting .each() loops. Her...

8
голосов
2ответов
4364 просмотров

Iteration through GroupCollection in C#

I'm currently trying to use regular expressions in C#: Regex reg_gameinfo = new Regex(@"PokerStars Game #(?<HID>[0-9]+):\s+(?:HORSE)? \(?(?<GAME>Hold'em|Razz|7 Card Stud|Omaha|Omaha Hi/Lo|Badugi) (?<LIMIT>No Limit|Limit|Pot Limit),? \(?(?<CURRENCYSIGN>\$|)?(?<SB>[.0...

2
голосов
5ответов
2957 просмотров

How can I iterate through nested arrays?

I have created an array as follows while (defined ($line = `<STDIN>`)) { chomp ($line); push @stack,($line); } each line has two numbers. 15 6 2 8 how do iterate over each item in each line? i.e. I want to print 15 6 2 8 I understand it's somet...

1
голосов
6ответов
76 просмотров

How can I set only the outer booleans of a 2d array to false?

If I have a 2d array like: boolean[][] map = new boolean[50][50]; How can I set the outer edge of booleans to true only in a loop? So, for the following array: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 You would have: 1 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 ...

41
голосов
8ответов
56126 просмотров

escaping the .each { } iteration early in Ruby

code: c = 0 items.each { |i| puts i.to_s # if c > 9 escape the each iteration early - and do not repeat c++ } I want to grab the first 10 items then leave the "each" loop. What do I replace the commented line with? is there a better approach? something more ...

2
голосов
11ответов
3048 просмотров

Simple 'for' loop crashing program on final iteration

The below program seems to be crashing at the very end each time, and I'm assuming that this is because once I get to i = (size-1) then wordList[i+1] won't return anything, returns null, or something equivalent. Any way around this? Am I correct that this is the source of my problem? #include &l...

14
голосов
16ответов
9014 просмотров

C: Looping without using looping statements or recursion

I want to write a C function that will print 1 to N one per each line on the stdout where N is a int parameter to the function. The function should not use while, for, do-while loops, goto statement, recursion, and switch statement. Is it possible?

6
голосов
1ответов
1372 просмотров

Is LINQ Join operator using Nested Loop, Merge, or HashSet Joins?

Does anyone know what Join algorith does LINQ performs with its Join operator. Is it NestedLoop, Merge, or HashSet? Is there any way to specify a different one, if supported? Regards Albert

2
голосов
1ответов
623 просмотров

Can you use the lapply() function to alter the value of input?

I was wondering whether it is possible to use the lapply() function to alter the value of the input, similar to: a1<-runif(100) a2<-function(i){ a1[i]<-a1[i-1]*a1[i];a1[i] } a3<-lapply(2:100,a2) I'm looking for something akin to a for() loop, but using the lapply() infrastructure. ...

13
голосов
3ответов
89292 просмотров

Double For loops in R

How do you properly write a double for loop in R? For example, in C I would do int i, j; for (i = 1; i < 6; i++) { for (j=i; j <= 3; j++) { printf("%i,%i\n",i,j); } // Do more operations for i > 3... } which would generate the (artificial) sequence: 1,1 1,2 1,3 2...

21
голосов
3ответов
15237 просмотров

How does a function in a loop (which returns another function) work?

I've been trying to assign a function to onclick event of a dynamically created "a" tag in JavaScript. All of the tags are created in a loop as follows: for ( var i = 0; i < 4; i++ ) { var a = document.createElement( "a" ); a.onclick = function( ) { alert( i ) }; document.getElementById(...

0
голосов
1ответов
818 просмотров

Php foreach loop, with looping error messages

I have a foreach loop that is suppose to check to see if a checkbox is checked by an item. If the checkbox is checked I need to see if the file upload part of the script has a value and if so then proceed to check the file type and size of the file the user is trying to upload. Currently if the...

3
голосов
3ответов
37584 просмотров

Looping a multidimensional array in php

I have a multidimensional array like this: array(2) { [1]=> array(3) { ["eventID"]=> string(1) "1" ["eventTitle"]=> string(7) "EVENT 1" ["artists"]=> array(3) { [4]=> array(2) { ["name"]=> string(8) "ARTIST 1" ["de...

0
голосов
1ответов
122 просмотров

Categorizing non-ID categories PHP loop

On my project there're various search results of different content-types. For unimportant reasons, not all content-types carry a unique ID. However, I tried to write this loop that will detect IDless content-types, and will give them a unique ID. Basically, the results look like this: Category...

0
голосов
1ответов
2598 просмотров

How to apply Loop to working Python Selenium Script?

I'm trying to figure out how to apply a for-loop to this script and I'm having a lot of trouble. I want to iterate through a list of subdomains which are stored in csv format (ie: one column with 20 subdomains) and print the html for each. They all have the same SourceDomain. Thanks! #Python ...

4
голосов
1ответов
898 просмотров

using Linq to generate a collection of things to be removed from another collection

I'm familiar with the problem of modifying a collection while looping over it with a foreach loop (i.e. "System.InvalidOperationException: Collection was modified"). However, it doesn't make sense to me that when I use Linq to create a List of keys to delete from a dictionary, then loop over my ...

4
голосов
5ответов
432 просмотров

Will this code be evaluated on every iteration?

I have this for-each-loop: for (Component c : container.getComponents()) { // Loop code } Is getComponents called on every iteration? Does it make sense to call getComponents before the look and only work on a cached array?

-1
голосов
2ответов
291 просмотров

Loop Problem: Assign data to different strings when in a loop

I have a string which consists of different fields. So what I want to do is get the different text and assign each of them into a field. ex: Hello Allan IBM so what I want to do is: put these three words in different strings like string Greeting = "Hello" string Name = "Allan" string Company ...