Latest recipes tagged "infinite"http://code.activestate.com/recipes/tags/infinite/new/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> Python Infinite Rotations and Tails (Python) 2011-02-13T15:27:42-08:00Thomas Ahlehttp://code.activestate.com/recipes/users/4060075/http://code.activestate.com/recipes/577574-python-infinite-rotations-and-tails/ <p style="color: grey"> Python recipe 577574 by <a href="/recipes/users/4060075/">Thomas Ahle</a> (<a href="/recipes/tags/cycles/">cycles</a>, <a href="/recipes/tags/functional/">functional</a>, <a href="/recipes/tags/infinite/">infinite</a>, <a href="/recipes/tags/lists/">lists</a>, <a href="/recipes/tags/rotations/">rotations</a>, <a href="/recipes/tags/tails/">tails</a>). </p> <p>This is an example of how functional ideas of infinite lists can be used in python to optimize memory usage of certain problems.</p> Infinite Stream Divisor (Python) 2010-07-21T12:50:17-07:00Narayana Chikkamhttp://code.activestate.com/recipes/users/4174427/http://code.activestate.com/recipes/577326-infinite-stream-divisor/ <p style="color: grey"> Python recipe 577326 by <a href="/recipes/users/4174427/">Narayana Chikkam</a> (<a href="/recipes/tags/divisor/">divisor</a>, <a href="/recipes/tags/infinite/">infinite</a>, <a href="/recipes/tags/stream/">stream</a>). </p> <p>Maintain an F.S.A to keep track of the consequent remainders as states, input symbols as driving actions on each state. O(N) is the time complexity to find the given large string [in some radix(R), for some specific divisor(D)], where N is the length of the Input String which confirms to the Language Rules under the alphabet. O(R*D) is the space complexity to keep the F.S.A in memory for lookup!</p>