Skip to content

Commit a6dcf89

Browse files
authored
Use any() in the list/tuple branch of occur_check (#1210)
occur_check returns whether var occurs in x; for lists/tuples use any(occur_check(var, e, s) for e in x) - a clean boolean check returning a proper bool - instead of first(...). Applied to logic.py and logic4e.py.
1 parent 91d3fe3 commit a6dcf89

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎logic.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,7 @@ def occur_check(var, x, s):
17661766
return (occur_check(var, x.op, s) or
17671767
occur_check(var, x.args, s))
17681768
elif isinstance(x, (list, tuple)):
1769-
return first(e for e in x if occur_check(var, e, s))
1769+
return any(occur_check(var, e, s) for e in x)
17701770
else:
17711771
return False
17721772

‎logic4e.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ def occur_check(var, x, s):
13581358
return (occur_check(var, x.op, s) or
13591359
occur_check(var, x.args, s))
13601360
elif isinstance(x, (list, tuple)):
1361-
return first(e for e in x if occur_check(var, e, s))
1361+
return any(occur_check(var, e, s) for e in x)
13621362
else:
13631363
return False
13641364

0 commit comments

Comments
 (0)