Longest common prefix: Difference between revisions
Content added Content deleted
Line 20: | Line 20: | ||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
<lang haskell>lcp :: [ |
<lang haskell>lcp :: (Eq a) => [[a]] -> [a] |
||
lcp = map head . takeWhile allEqual . truncTranspose where |
lcp = map head . takeWhile allEqual . truncTranspose where |
||
-- similar to transpose, but stops on end of shortest list |
-- similar to transpose, but stops on end of shortest list |