tagged [iteration]

Why can't we assign a foreach iteration variable, whereas we can completely modify it with an accessor?

Why can't we assign a foreach iteration variable, whereas we can completely modify it with an accessor? I was just curious about this: the following code will not compile, because we cannot modify a f...

20 Oct at 15:11

Replacement for for... if array iteration

Replacement for for... if array iteration I love list comprehensions in Python, because they concisely represent a transformation of a list. However, in other languages, I frequently find myself writi...

12 Sep at 05:14

Why is it bad to use an iteration variable in a lambda expression

Why is it bad to use an iteration variable in a lambda expression I was just writing some quick code and noticed this complier error > Using the iteration variable in a lambda expression may have unex...

18 Oct at 03:4

What is the difference between Sprint and Iteration in Scrum and length of each Sprint?

What is the difference between Sprint and Iteration in Scrum and length of each Sprint? 1. Is there a difference between Sprint and an Iteration or one can have Iterations within a Sprint or Sprint is...

Getting next element while cycling through a list

Getting next element while cycling through a list When this reaches the last element, an `IndexError` is raised (as is the case for any list, tuple, dictionary, or string that is iterated). I actually...

15 Oct at 12:3

C# or VB.NET - Iterate all Public Enums

C# or VB.NET - Iterate all Public Enums We have a common component in our source which contains all the enums (approx 300!) for a very large application. Is there any way, using either C# or VB.NET, t...

23 May at 12:0

How to iterate through a list of dictionaries in Jinja template?

How to iterate through a list of dictionaries in Jinja template? I tried: In the template: ``` Key Value {% for dictionary in list1 %} {% for key in dictionary %}

How to loop backwards in python?

How to loop backwards in python? I'm talking about doing something like: I can think of some ways to do so in python (creating a list of `range(1,n+1)` and reverse it, using `while` and `--i`, ...) bu...

13 Aug at 16:37

Is if(items != null) superfluous before foreach(T item in items)?

Is if(items != null) superfluous before foreach(T item in items)? I often come across code like the following: Basically, the `if` condition ensures that `foreach` block will execute only if `items` i...

7 Oct at 19:33

Java HashMap: How to get a key and value by index?

Java HashMap: How to get a key and value by index? I am trying to use a HashMap to map a unique string to a string ArrayList like this: Basically, I want to be able to access the keys by number, not b...

2 Feb at 22:14

remove html node from htmldocument :HTMLAgilityPack

remove html node from htmldocument :HTMLAgilityPack In my code, I want to remove the img tag which doesn't have src value. I am using object. I am finding the img which doesn't have src value and ...

iterating on enum type

iterating on enum type > [How do I enumerate an enum?](https://stackoverflow.com/questions/105372/how-do-i-enumerate-an-enum) I don't know if it is possible to do what I want to do, but I think why ...

23 May at 11:53

How to modify or delete items from an enumerable collection while iterating through it in C#

How to modify or delete items from an enumerable collection while iterating through it in C# I have to delete some rows from a data table. I've heard that it is not ok to change a collection while ite...

17 Jan at 15:42

How to iterate over a string in C?

How to iterate over a string in C? Right now I'm trying this: ``` #include int main(int argc, char *argv[]) { if (argc != 3) { printf("Usage: %s %s sourcecode input", argv[0], argv[1]); } el...

26 May at 20:9

How to iterate through enum type while skipping some values?

How to iterate through enum type while skipping some values? The key part of my question is the skipping. I plan to use an enum type that has about 20 elements. I want to iterate through this set but ...

12 Mar at 17:34

Iterate over C# dictionary's keys with index?

Iterate over C# dictionary's keys with index? How do I iterate over a Dictionary's keys while maintaining the index of the key. What I've done is merge a `foreach`-loop with a local variable `i` which...

2 May at 15:13

Iterate through properties of static class to populate list?

Iterate through properties of static class to populate list? I have a class of string constants, how can I loop through to get the string and populate a list-box? ``` static class Fields { static re...

18 Sep at 15:34

Is recursion ever faster than looping?

Is recursion ever faster than looping? I know that recursion is sometimes a lot cleaner than looping, and I'm not asking anything about when I should use recursion over iteration, I know there are lot...

25 Oct at 00:32

Iterating a dictionary in C#

Iterating a dictionary in C# ``` var dict = new Dictionary(); for (int i = 0; i

23 May at 11:46

Allowing iteration without generating any garbage

Allowing iteration without generating any garbage I have the following code in an object pool that implements the IEnumerable interface. ``` public IEnumerable ActiveNodes { get { for (int i =...

How do I access properties of a javascript object if I don't know the names?

How do I access properties of a javascript object if I don't know the names? Say you have a javascript object like this: You can access the properties by the property name: But is it possible to get t...

How to iterate through an ArrayList of Objects of ArrayList of Objects?

How to iterate through an ArrayList of Objects of ArrayList of Objects? Let say I have a class call `Gun`. I have another class call `Bullet`. Class `Gun` has an ArrayList of `Bullet`. To iterate thro...

17 Nov at 18:34

Iterating through a Collection, avoiding ConcurrentModificationException when removing objects in a loop

Iterating through a Collection, avoiding ConcurrentModificationException when removing objects in a loop We all know you can't do the following because of `ConcurrentModificationException`: But this a...

20 Oct at 13:4

Does iteratee I/O make sense in non-functional languages?

Does iteratee I/O make sense in non-functional languages? In Haskell, [Iteratee based I/O](http://www.haskell.org/haskellwiki/Iteratee_I/O) seems very attractive. Iteratees are a composable, safe, fas...

22 Jul at 20:6

Python list iterator behavior and next(iterator)

Python list iterator behavior and next(iterator) Consider: So, advancing the iterator is, as expected, handled by mutating that same object. This being the case, I would expect: to skip every second e...

4 Sep at 15:5