enumerator Questions
4
I have been debugging this production bug for sometime and I'm desperate for help and also it's interesting to me.
I have simplified the code logic and added some print-out for debugging:
int[] a...
Cheery asked 23/4, 2015 at 9:21
4
I'm having a problem with a Windows Form application I'm building in C#. The error is stating "foreach statement cannot operate on variables of type 'CarBootSale.CarBootSaleList' because 'CarBootSa...
Penton asked 1/3, 2013 at 13:32
2
Solved
There are several situations where I'd like to apply a block to a certain value and use the value inside this block, to use the enumerator coding style to every element.
If such method would be c...
Sump asked 15/10, 2014 at 9:20
2
Solved
In this example,
[1, 2, 3].each_with_index.map{|i, j| i * j}
# => [0, 2, 6]
my understanding is that, since each_with_index enumerator is chained to map, map behaves like each_with_index by p...
Fleshy asked 13/6, 2014 at 7:30
2
Solved
In the framework classes of collections I have often seen IEnumerator<T> separately implemented as an inner class and an instance of it is returned in the GetEnumerator method.
Now suppose ...
Heyman asked 10/6, 2014 at 13:41
2
Solved
Let's say you wrote a custom enumerator for the code below:
public class School : IEnumerable<Student>
And then in the client code, you did this:
static void Main(string[] args)
{
var sc...
Prelude asked 9/5, 2014 at 20:55
6
Solved
I'm trying to track down a bug in our code. I've boiled it down to the snippet below. In the example below I have a grid of ints (a list of rows), but I want to find the indexes of the columns that...
Shoemaker asked 8/5, 2014 at 9:16
1
I'd like to optimize following code for conciseness.
x1.each { |x|
x2.each { |y|
....
xN.each { |z|
yield {}.merge(x).merge(y)...... merge(z)
}
}
}
Assume x1, x2, ..., xN are Enumerator o...
Justinajustine asked 7/5, 2014 at 13:11
1
I want to call a common enumerator from different threads. When I do the following,
enum = (0..1000).to_enum
t1 = Thread.new do
p enum.next
sleep(1)
end
t2 = Thread.new do
p enum.next
sleep(1)...
Streeter asked 23/2, 2014 at 9:35
1
Solved
Why does this return nil and what does line 2 mean? The array represents rows of a Sudoku puzzle which I'm trying to create a solution for.
I'm trying different methods in irb to see how many dif...
Ennui asked 28/1, 2014 at 21:7
3
Solved
I'm using yield return to iterate over an SqlDataReader's records:
IEnumerable<Reading> GetReadings() {
using (var connection = new SqlConnection(_connectionString))
{
using (var command ...
Douma asked 24/1, 2014 at 16:13
1
Solved
When setting up a for each loop to read products from an "objProduct" object variable, I got three options in "Enumerator Mode" pane as snapshot shows:
I know "Rows in the first table" is the r...
Schick asked 31/12, 2013 at 17:54
6
Solved
In the Ruby Array Class documentation, I often find:
If no block is given, an enumerator is returned instead.
Why would I not pass a block to #map? What would be the use of my doing just:
[1,...
Pore asked 5/12, 2013 at 8:26
3
Solved
This code, from an example I found, counts the number of elements in the array which are equal to their index. But how ?
[4, 1, 2, 0].to_enum(:count).each_with_index{|elem, index| elem == index}
...
Wits asked 21/10, 2013 at 15:47
2
Solved
Is there a way to do:
a = b.map{ |e| #return multiple elements to be added to a }
Where rather than returning a single object for each iteration to be added to a, multiple objects can be returne...
Laevo asked 14/9, 2013 at 9:27
6
How to get an Enumerator to an item in a -Sorted- dictionary using key?
Note:GetEnumerator() gets an Enumerator to first element..
But I need to get an Enumerator to the element with a given key ...
Retrieval asked 27/7, 2010 at 9:55
3
Solved
I'm trying to use the scalaz iteratee package to process a large zip file in constant space. I have a long-running process I need to perform on each file in the zip file. Those processes can (and s...
Preconscious asked 26/4, 2013 at 3:14
6
Solved
How can I enumerate through all the key/values of
a FormCollection (system.web.mvc) in ASP.NET MVC?
Borglum asked 18/4, 2009 at 3:23
1
Solved
If I call the GetEnumerator method of a Generics.Collections object, do I need to explicitly free the enumerator when I'm done with it?
Tical asked 18/4, 2013 at 15:19
4
Solved
Lets assume you have a function that returns a lazily-enumerated object:
struct AnimalCount
{
int Chickens;
int Goats;
}
IEnumerable<AnimalCount> FarmsInEachPen()
{
....
yield new Anima...
Erickaericksen asked 28/3, 2013 at 19:28
3
Solved
I'm practicing deletion of nodes on a binary search tree, and I created a special type for null links (NullNode) using null pattern, so I can add some desirable behaviour to "null" types. Both Node...
Niche asked 3/11, 2012 at 20:20
4
Solved
Ok maybe this is simple but...
given this:
arr = ("a".."z").to_a
arr
=> ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x"...
Aliciaalick asked 23/10, 2012 at 1:15
2
Solved
I wonder wether it is feasible to implement an optimal string generator Class meeting the following second thought requirements:
Generation criteria using regex
Lexicographical order enumerat...
Bohunk asked 5/4, 2012 at 17:25
4
Solved
I'm basicly trying to make my class able to iterate using foreach. I read this tutorial. MSDN. It seems very straight forward. However, I have a problem when I want to iterate second time. I debugg...
Allotropy asked 13/7, 2012 at 17:21
3
I've been researching the similarities/differences between Ruby and Python generators (known as Enumerators in Ruby), and so far as i can tell they're pretty much equivalent.
However one differen...
Unset asked 25/9, 2010 at 17:25
© 2022 - 2024 — McMap. All rights reserved.