[Assorted-commits] SF.net SVN: assorted: [686] python-commons/trunk/src/commons/seqs.py
Brought to you by:
yangzhang
|
From: <yan...@us...> - 2008-04-29 00:31:42
|
Revision: 686
http://assorted.svn.sourceforge.net/assorted/?rev=686&view=rev
Author: yangzhang
Date: 2008-04-28 17:31:41 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
addec countstep
Modified Paths:
--------------
python-commons/trunk/src/commons/seqs.py
Modified: python-commons/trunk/src/commons/seqs.py
===================================================================
--- python-commons/trunk/src/commons/seqs.py 2008-04-25 21:38:05 UTC (rev 685)
+++ python-commons/trunk/src/commons/seqs.py 2008-04-29 00:31:41 UTC (rev 686)
@@ -341,6 +341,15 @@
del chunk[ ( i + 1 ) % n : ]
yield chunk
+def countstep(start, step):
+ """
+ Generate [start, start+step, start+2*step, start+3*step, ...].
+ """
+ i = start
+ while True:
+ yield i
+ i += step
+
def take(n, seq):
return list(islice(seq, n))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|