File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
source_py3/python_toolbox Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments