Iterations are the successive repetitions in loops such as for, foreach or while. Questions with this tag are often concerned about how to best handle a collection of data.
-3
votes
2answers
34 views
Java: Using ArrayList to iterate
Given these classes:
public class Car {
private int registrationNumber;
private String automaker;
private String colour;
private int numberOfSeats;
public Car {
setRegistrationNumber(int regNum);
...
0
votes
3answers
59 views
Python: double loop modify iterator
I'm new in Python but basically I want to create sub-groups of element from the list with a double loop, therefore I gonna compare the first element with the next to figure out if I can create these ...
0
votes
0answers
8 views
Iterating function over dataframe columns with mixed function results
I have looked on the forum, and tried a few of the (seemingly fitting) "solutions", however I do not believe that any of them are directly suitable.
I have a function that currently looks something ...
1
vote
2answers
26 views
DIfferent behavior on last iteration with php foreach
I have a basic php script that loops through a bunch of custom fields (in wordpress):
<?php foreach( $images as $image ): ?>
{image: '<?php echo $image['url']; ?>', thumb: '<?php ...
-1
votes
1answer
34 views
Loop taking longer inexplicably [closed]
I know thats a vague title - perhaps because the question is vague!
I have a python procedure that loops through every item (an object i defined) in a set performing a function on each of the ...
2
votes
1answer
41 views
Python itertools combinations iteration control
I am using itertools to generate combinations, but I would like to control the output and be able to ask for the next entry:
from itertools import permutations
def getPass():
chars = ...
0
votes
2answers
21 views
Iterating over JSONObject in GWT JSNI
I have a native method which should iterate over the JSONObject. Is there a way to achieve this?
public native void foo(JSONObject c)/*-{
var keys = ...
0
votes
1answer
20 views
Setting a Value in a Nested Python List Automatically Iterates
I have a python list, created by model = [[[[0,0,0,0]]*4]*15]*5, which is a list that looks like this (without the brevity dots): model = ...
1
vote
3answers
48 views
Change index variable within ruby loop
I realize this may be against ruby principle and may seem a bit silly, but I am curious to whether it possible to modify the index variable during iteration of a loop in ruby.
This practice is ...
1
vote
1answer
18 views
Selecting and counting each iteration with PDO
I am trying to SELECT all the distinct values from my table and count the number of iterations per value.
I am using this:
$ordered = $con->prepare("SELECT COUNT(itemId) as countId, itemId FROM ...
-1
votes
0answers
22 views
gtk_main_iteration does not working
Why label_path doesn't refresh?
gtk_label_set_text(GTK_LABEL(label_path), "Loading...");
while(gtk_events_pending())
{
gtk_main_iteration();
}
0
votes
1answer
36 views
boost unordered_map reverse foreach
I have found, that BOOST_REVERSE_FOREACH doesn't work in the same way as BOOST_FOREACH.
My code:
#include <boost\unordered_map.hpp>
#include <boost\foreach.hpp>
#include <iostream>
...
0
votes
2answers
72 views
Convert a for-loop to a recursive function
Can anyone help to convert this to a recursion function?
def max_vel(t):
vel = 0
thr = 10
c = -0.1
for i in range(t):
fric = c * vel
acc = thr + fric
vel = ...
0
votes
1answer
41 views
For Loop inside Function using a List: not iterating
Hello :) In the typing practice program I am creating in python 3, I have a for...loop that takes the characters from a global list of a certain paragraphs characters and compares it to the character ...
0
votes
3answers
68 views
Evaluating Polynomial coefficients
I'm trying to write a function that takes as input a list of coefficients (a0, a1, a2, a3.....a n) of a polynomial p(x) and the value x. The function will return p(x), which is the value of the ...