Skip to content

Commit 88db75c

Browse files
committed
-
1 parent 1fb302d commit 88db75c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

source_py3/python_toolbox/logic_tools.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@ def all_equal(iterable, exhaustive=False):
2424
# todo: Maybe I should simply check if `len(set(iterable)) == 1`? Will not
2525
# work for unhashables.
2626

27+
items = tuple(iterable)
28+
if len(items) <= 1:
29+
return True
30+
2731
if exhaustive is True:
2832
from python_toolbox import combi
29-
items = tuple(iterable)
3033
pairs = tuple(
3134
tuple(items[i] for i in comb) for comb in
32-
combi.CombSpace(len(items), min(2, len(items)))
35+
combi.CombSpace(len(items), 2)
3336
)
3437
else: # exhaustive is False
35-
pairs = cute_iter_tools.iterate_overlapping_subsequences(iterable)
38+
pairs = cute_iter_tools.iterate_overlapping_subsequences(items)
3639

3740
return all(a==b for (a, b) in pairs)
3841

0 commit comments

Comments
 (0)