[Nym3-commit] r448 - trunk/nymbaron

laurent at conuropsis.org laurent at conuropsis.org
Sun Feb 5 18:34:24 CET 2006


Author: laurent
Date: 2006-02-05 18:34:22 +0100 (Sun, 05 Feb 2006)
New Revision: 448

Modified:
   trunk/nymbaron/Common.py
Log:
Make pylint happy.


Modified: trunk/nymbaron/Common.py
===================================================================
--- trunk/nymbaron/Common.py	2006-02-05 16:11:33 UTC (rev 447)
+++ trunk/nymbaron/Common.py	2006-02-05 17:34:22 UTC (rev 448)
@@ -45,20 +45,22 @@
 
 #functions
 
-def binsearch(l, prop):
-    """Returns the first index i of l for which l[i] is true,
-       assuming prop is increasing over l"""
-    min = 0
-    max = len(l) - 1
-    if not prop(l[max]): return IndexError
-    if prop(l[min]): return min
+def binsearch(slist, prop):
+    """Returns the first index i of slist for which slist[i] is true,
+       assuming prop is increasing over slist"""
+    minindex = 0
+    maxindex = len(slist) - 1
+    if not prop(slist[maxindex]):
+        return IndexError
+    if prop(slist[minindex]):
+        return minindex
 
-    current = (max + min) / 2
-    while max - min > 1:
-	if prop(l[current]):
-	    max = current
-	    current = (max + min) / 2
-	else:
-	    min = current
-	    current = (max + min) / 2
-    return max
+    current = (maxindex + minindex) / 2
+    while maxindex - minindex > 1:
+        if prop(slist[current]):
+            maxindex = current
+            current = (maxindex + minindex) / 2
+        else:
+            minindex = current
+            current = (maxindex + minindex) / 2
+    return maxindex



More information about the Nym3-commit mailing list