Steady squares: Difference between revisions
Content added Content deleted
(→Python :: Functional: Updated first version to use concatMap and .endswith) |
(→Python :: Functional: Updated accumulating version to use .endswith) |
||
Line 1,029: | Line 1,029: | ||
) |
) |
||
) |
) |
||
) if |
) if str(b).endswith(str(a)) |
||
) |
) |
||
) |
) |
||
# ----------------------- 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 |
|||