Steady squares: Difference between revisions

→‎Python :: Functional: Updated accumulating version to use .endswith
(→‎Python :: Functional: Updated first version to use concatMap and .endswith)
(→‎Python :: Functional: Updated accumulating version to use .endswith)
Line 1,029:
)
)
) if isSuffixOf(str(a)b).endswith(str(ba))
)
)
 
 
# ----------------------- GENERIC ------------------------
 
# isSuffixOf :: (Eq a) => [a] -> [a] -> Bool
def isSuffixOf(needle):
'''True if needle is a suffix of haystack.
'''
def go(haystack):
d = len(haystack) - len(needle)
return d >= 0 and (needle == haystack[d:])
return go
 
 
9,659

edits