generator

Nicest, efficient way to get result tuple of sequence items fullfilling and not fullfilling condition

(This is professional best practise/ pattern interest, not home work request) INPUT: any unordered sequence or generator items, function myfilter(item) returns True if filter condition is fulfilled OUTPUT: (filter_true, filter_false) tuple of sequences of original type which contain the elements partitioned according to filter in origi...

How to generate random events in android?

I have a an array of objects and would like to be able to randomly choose one from the list when a button is pressed. How would you do that in Android? ...

Testing a query builder

I am building a query builder that I want to unit test. I don't know how to go about it though. It (currently) consists of two parts: the QueryBuilder itself which provides a fluent interface for constructing queries. And a SqlConstructor that takes care of constructing the actual SQL. So basically, how do I test 'correctness'? Should ...

Automatically generate value for a column in database

I've an existing table with 'creation time' column in one of the table. I want the value of it to be generated automatically by the Oracle when the row gets inserted, instead of me populating in the application. Thank You ...

What does this python syntax mean?

I am not a python guy and I am trying to understand some python code. I wonder what the last line of below code does? Is that kind of multiple objects returned? or list of 3 objects returned? req = SomeRequestBean() req.setXXX(xxx) req.YYY = int(yyy) device,resp,fault = yield req #<----- What does this mean ? ...

Very noob python question: How to print what I think is an object?

test = ["a","b","c","d","e"] def xuniqueCombinations(items, n): if n==0: yield [] else: for i in xrange(len(items)-n+1): for cc in xuniqueCombinations(items[i+1:],n-1): yield [items[i]]+cc x = xuniqueCombinations(test, 3) print x outputs "generator object xuniqueCombinations at 0x020EBFA8"...

What is a good parser generator for php?

I need to parse a small 'mini language' which users can type on my site. I was wondering what the counterparts of lex and jacc or antlr are for the world of php. ...

F# generator of daterange?

I'm attempting to write a function that generates a list of DateTimes using the generator syntax: let dateRange = let endDate = System.DateTime.Parse("6/1/2010") let startDate = System.DateTime.Parse("3/1/2010") seq { for date in startDate..endDate do if MyDateClass.IsBusinessDay(date) then yield d...

.net generate constructor based on fields .net

Hello guys, I'm producing very code using Identities Project to represent the objects, but it is some 1000 entities, and i need to know if exists some plugin or something .net free than produces auto contructor to each instance based on class fields. Example class Thing { public readonly string a; public readonly Object b; } // ...

generate documentation from javascript

How are you generate documentation for javascript ? Especially in a rails application ? Any plugins to rdoc or something similar ? ...

How to use a generator to iterate over a tree's leafs

The problem: I have a trie and I want to return the information stored in it. Some leaves have information (set as value > 0) and some leaves do not. I would like to return only those leaves that have a value. As in all trie's number of leaves on each node is variable, and the key to each value is actually made up of the path necessary...

Symfony 1.4: Problems displaying a field depending on the credentials user in the admin generator

Hi everyone, I'm working with symphony 1.4 with the Doctrine ORM. I want to display in the edit and list action some fields of a form depending on the credentials of the user. An example, if the user has admin credentials, the filed secret_notes will appear and it could be modified. Otherwise it doesn't appear and it couldn't be modifie...

What are C# Iterators and Generators, and how could I utilize them

I am a VB.Net developer, kind of newbie in C#, While looking in C# documentation I came through Iterators and Generators, could not fully understand the use, I there anyone who can explain (in vb perceptive; if possible) ...

Generate UML class diagrams from C++ source files?

With doxygen I can generate nice diagrams but doxygen lacks a deeper analysis of the relationships between classes. It recognizes derivation but other relations are not understood by the tool. Which better utilities are there (commercial or not) that generate more complete UML class diagrams out of C++ source files? PS: The tools availa...

Ruby generators vs Python generators

Hi, 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 difference i've noticed is that Python Generators support a close() method whereas Ruby Generators do not. From the Python docs the close() meth...

What are python generators?

Possible Duplicate: What can you use Python generator functions for? I tried to read about python generators but did not understand much about the concept as to what we can do with generators, I am new to python please let me know Thank you ...

generator/block to iterator/stream conversion

Basically I want to convert this: def data(block: T => Unit) to a Stream (dataToStream is a hypothetical function that do this conversion): val dataStream: Stream[T] = dataToStream(data) I suppose this problem could be resolved by continuations: // let's assume that we don't know how data is implemented // we just know that it gen...

Processing lines of shell command stdout lazily in python

I'm working on a toy language, and I've implemented the ability to stream lines of text from shell commands lazily (as a generator). Currently, my code to do this looks like: #!/usr/bin/env python3 import signal,subprocess,select # suppress 'broken pipe' error messages signal.signal(signal.SIGPIPE, signal.SIG_DFL) def shell_exec(cmd)...

itertools or hand-written generator - what is preferable?

I have a number of Python generators, which I want to combine into a new generator. I can easily do this by a hand-written generator using a bunch of yield statements. On the other hand, the itertools module is made for things like this and to me it seems as if the pythonic way to create the generator I need is to plug together various ...

How to use generators with IndexedDB?

Hi all :) I'm trying out IndexedDB, but I can't seem to make it work with generators, even though it was advised as one way to make IndexedDB easier to use. The following code works (not using generators): function loadItems (func_item) { var request = db.objectStore ("store").openCursor (); request.onsuccess = function (event) {...