Created
May 19, 2018 17:20
-
-
Save JackTheEngineer/78127defe3196d70d811b6e50d28a15a 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
import Test.QuickCheck | |
import Data.List (intersperse) | |
split :: Char -> String -> [String] | |
split c [] = [] | |
split c xs = xs' : if null xs'' then [] else split c (tail xs'') | |
where xs' = takeWhile (/=c) xs | |
xs''= dropWhile (/=c) xs | |
unsplit :: Char -> [String] -> String | |
unsplit c = concat . intersperse [c] | |
-- show | |
prop_split_inv c xs = unsplit c (split c xs) == xs | |
main = quickCheck prop_split_inv | |
-- /show |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment