Created
August 9, 2010 21:51
-
-
Save njbartlett/516197 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Find the longest shared prefix of two lists | |
-- e.g. findPrefix [1,2,3,4] [1,2,3,5] returns [1,2,3] | |
findPrefix :: (Eq a) => [a] -> [a] -> [a] | |
findPrefix xs = map fst . takeWhile (uncurry (==)) . zip xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment