Sometimes the more pythonic notation can obfuscate the intent, does anyone agree?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def CountPointOnEdges(point, edges): | |
''' returns the number of edges that a point lies on. ''' | |
v1, v2, v3, v4 = edges | |
count = 0 | |
if(isPointOnEdge(point, v1, v2)): count+=1 | |
if(isPointOnEdge(point, v3, v4)): count+=1 | |
return count | |
def CountPointOnEdges(point, edges): | |
''' returns the number of edges that a point lies on. ''' | |
edges = zip(*[iter(edges)]*2) | |
return sum([1 for edge in edges if isPointOnEdge(point, *edge)]) |