Popular recipes tagged "itertools" but not "python"http://code.activestate.com/recipes/tags/itertools-python/2012-05-04T14:09:14-07:00ActiveState Code RecipesRecursively defined, Haskell-style infinite lists (Python)
2012-05-04T14:09:14-07:00John Crichtonhttp://code.activestate.com/recipes/users/4181975/http://code.activestate.com/recipes/578119-recursively-defined-haskell-style-infinite-lists/
<p style="color: grey">
Python
recipe 578119
by <a href="/recipes/users/4181975/">John Crichton</a>
(<a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/functional/">functional</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/infinite/">infinite</a>, <a href="/recipes/tags/itertools/">itertools</a>, <a href="/recipes/tags/lazy/">lazy</a>, <a href="/recipes/tags/recursive/">recursive</a>).
Revision 2.
</p>
<p>A decorator to simplify the creation of recursively defined, Haskell-style infinite lists -- ie. recursive generators -- inspired by Raymond Hettinger's "Technique for cyclical iteration" [*]. </p>
<p>[*] <a href="http://code.activestate.com/recipes/576961-technique-for-cyclical-iteration/" rel="nofollow">http://code.activestate.com/recipes/576961-technique-for-cyclical-iteration/</a> </p>
Iterator Offsetter (Python)
2012-04-16T13:08:55-07:00Josh Bodehttp://code.activestate.com/recipes/users/4179046/http://code.activestate.com/recipes/577852-iterator-offsetter/
<p style="color: grey">
Python
recipe 577852
by <a href="/recipes/users/4179046/">Josh Bode</a>
(<a href="/recipes/tags/iterable/">iterable</a>, <a href="/recipes/tags/itertools/">itertools</a>, <a href="/recipes/tags/offset/">offset</a>).
Revision 2.
</p>
<p>Produces a list of copies of an iterable that are offset by the supplied offsets.</p>
lazy ordered unique elements from an iterator (Python)
2011-06-23T16:36:38-07:00Andrew Dalkehttp://code.activestate.com/recipes/users/912777/http://code.activestate.com/recipes/577768-lazy-ordered-unique-elements-from-an-iterator/
<p style="color: grey">
Python
recipe 577768
by <a href="/recipes/users/912777/">Andrew Dalke</a>
(<a href="/recipes/tags/iterator/">iterator</a>, <a href="/recipes/tags/itertools/">itertools</a>, <a href="/recipes/tags/unique/">unique</a>).
Revision 2.
</p>
<p>This implements a "unique" filter. Its input is an iterator of hashable items. It returns an iterator containing only the unique items of the input, in input order. That is, list(unique("cabbage")) produces ["c", "a", "b", "g"]. The implementation is lazy. The function supports the "key" parameter, which provides an alternate form of comparison.</p>
<p>(Note: a better version of this is available from the itertools documentation as unique_everseen )</p>
Yet another roundrobin (Python)
2010-07-19T13:53:41-07:00Daniel Cohnhttp://code.activestate.com/recipes/users/4172918/http://code.activestate.com/recipes/577309-yet-another-roundrobin/
<p style="color: grey">
Python
recipe 577309
by <a href="/recipes/users/4172918/">Daniel Cohn</a>
(<a href="/recipes/tags/collections/">collections</a>, <a href="/recipes/tags/itertools/">itertools</a>, <a href="/recipes/tags/roundrobin/">roundrobin</a>).
Revision 2.
</p>
<p>This recipe provides a decently simple implementation of a roundrobin using itertools and deque.</p>
Flattened List (Python)
2009-04-27T18:41:21-07:00marlonamorhttp://code.activestate.com/recipes/users/4169863/http://code.activestate.com/recipes/576719-flattened-list/
<p style="color: grey">
Python
recipe 576719
by <a href="/recipes/users/4169863/">marlonamor</a>
(<a href="/recipes/tags/flat/">flat</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/itertools/">itertools</a>, <a href="/recipes/tags/list/">list</a>, <a href="/recipes/tags/nested/">nested</a>).
Revision 2.
</p>
<p>This flattenizes any nested level list. I couln't find this in itertools module so I wrote it. Python 3 may be required.</p>