Longest common suffix: Difference between revisions
Content deleted Content added
m →{{header|Haskell}}: Reduced slightly with foldr |
→{{header|Python}}: (replaced `reversed` and a comprehension) with reduce |
||
Line 347: | Line 347: | ||
from itertools import takewhile |
from itertools import takewhile |
||
from functools import reduce |
|||
Line 357: | Line 358: | ||
h = cs[0] |
h = cs[0] |
||
return all(h == c for c in cs[1:]) |
return all(h == c for c in cs[1:]) |
||
⚫ | |||
def firstCharPrepended(s, cs): |
|||
⚫ | |||
return cs[0] + s |
|||
⚫ | |||
firstCharPrepended, |
|||
⚫ | |||
p, |
p, |
||
zip(*(reversed(x) for x in xs)) |
zip(*(reversed(x) for x in xs)) |
||
) |
), |
||
'' |
|||
) |
|||