What would you name a function that takes a list and a function, and returns True if applying the function to all elements gives the same result?
def identical_results(l, func):
if len(l) <= 1: return True
result = func(l[0])
for el in l[1:]:
if func(el) != result:
return False
return True
Is there a nice generally accepted name for this thing? Bonus if you can implement in a less clunky fashion.