yield

How yield implements the pattern of lazy loading?

How yield implements the pattern of lazy loading? ...

How would I yield an immutable.Map in Scala?

I have tried this but it does not work: val map:Map[String,String] = for { tuple2 <- someList } yield tuple2._1 -> tuple2._2 How else would I convert a List of Tuple2s into a Map? ...

Implications of calling yield() twice

What are the implications of calling yield() twice? For example - if yield :content_header yield :content_header - else No Content Header Is this going to eat up little bits of time? I can't seem to get content_for? to work :/ ...

Is there any parallel in Objective-C to C#'s yield keyword

The first time I saw the yield keyword in C# I thought "yuck what a way to junk up the language". Having grown since then and actually used the language I find it so pleasantly simple to express state logic that I'd like to use a similar approach in other development platforms. I'm exploring Objective-C for some support utilities. Is ...

Ruby using yield and got this problem: Cannot yield from a Proc type filter.

Im using like this: def child_render super_render { print GridModule.new.render } end def super_render @yield_value = yield end and got: Cannot yield from a Proc type filter. The Proc must take two arguments and execute #call on the second argument. ...

Custom Collection Implementing IEnumerable

I know that technically, an Interface is used for reading and not writting or editing however, I want to add an add and addrange function to the following class, here is what I currently have which is not working public class HrefCollection : IEnumerable<Href> { private IEnumerable<Href> hrefs; public IEnumerable<Href> Add( Hr...

What is the equilivant syntax in vb.net for "yield return"?

Using the c# code below, how would you write it in vb? What is it trying to say? using System; using System.Collections.Generic; using System.IO; using System.Windows; using System.Windows.Media; using System.Windows.Media.Imaging; namespace Microsoft.LiveLabs.Pivot { /// <summary> /// Tile Builder class /// </summary> ...

using yield in C# like I would in Ruby

Besides just using yield for iterators in Ruby, I also use it to pass control briefly back to the caller before resuming control in the called method. What I want to do in C# is similar. In a test class, I want to get a connection instance, create another variable instance that uses that connection, then pass the variable to the callin...

When is 'Yield' really needed?

Possible Duplicate: C# - Proper Use of yield return What can be a real use case for C# yield? Thanks. ...

Yield only as many are required from a generator

I wish to yield from a generator only as many items are required. In the following code a, b, c = itertools.count() I receive this exception: ValueError: too many values to unpack I've seen several related questions, however I have zero interest in the remaining items from the generator, I only wish to receive as many as I ask for...

invoking yield for a generator in another function

suppose I have some manager object. This object's API has a main_hook function, that gets another function f as it's argument, and runs the given f in a loop, doing some stuff in between each iteration: def main_hook(self,f): while (self.shouldContinue()): #do some preparations f(self) #do some tear down No...

Python: get number of items in generator without storing the items

I have a generator for a large set of items. I want to iterate through them once, outputting them to a file. However, with the file format I currently have, I first have to output the number of items I have. I don't want to build a list of the items in memory, as there are too many of them and that would take a lot of time and memory. Is...

Serializing IEnumerator<T> created using yield return

Is there a way to serialize (using BinaryFormatter) the IEnumerator<T> that gets created when I use yield returns? The autogenerated class isn't marked Serializable. ...

Can params be used to pass variables by ref via a function using yield

If I have a method that has a params parameter, can it be passed by reference and updated every time a yield is called. Something like this: public static void GetRowsIter(ref params valuesToUpdate) { foreach(row in rows) { foreach(param in valuesToUpdate { GetValueForParam(param) } yield;...

does linq where call reduce calls to my database (Custom built)

I have a method that gets rows from my database. It looks like this: public static IEnumerable<Dictionary<string, object>> GetRowsIter() { _resultSet.ReadFirst(); do { var resultList = new Dictionary<string, object>(); for (int fieldIndex = 0; fieldIndex < _resultSet.FieldCount; fieldIndex++) { ...

What is yield?, and what is the benifit to use yield in asp.net ?

Hi Experts, can you help me in understanding of yield keyword in asp.net(C#). Thanks Vij ...

What is the benefit of "yield" keyword from WEB disconnected architecture point of view

After reading various posts and SO questions, I understand that If we have very long chain of data then going with yield can be good but please tell me how it is proficient as far as ASP.NET or you can say disconnected web architecture point of view. For example I am bringing my data from database through DAL and now the connection is di...

Using yield from an event handler

I have a method Foo.LongRunningMethod(), which does some very complicated processing that may go on for a long time. Along the way, it fires Foo.InterestingEvent whenever it encounters a certain condition. I'd like to be able to expose an enumeration of those events, and I'd like to be able to start iterating before LongRunningMethod act...

Multiple yields in sequence comprehension?

I'm trying to learn Scala and tried to write a sequence comprehension that extracts unigrams, bigrams and trigrams from a sequence. E.g., [1,2,3,4] should be transformed to (not Scala syntax) [1; _,1; _,_,1; 2; 1,2; _,1,2; 3; 2,3; 1,2,3; 4; 3,4; 2,3,4] In Scala 2.8, I tried the following: def trigrams(tokens : Seq[T]) = { var t1 : ...

Does python yield imply continue?

I have a for loop that checks a series of conditions. On each iteration, it should yield output for only one of the conditions. The final yield is a default, in case none of the conditions are true. Do I have to put a continue after each block of yields? def function(): for ii in aa: if condition1(ii): yield som...