I was wondering if there would be a concise/one-liner way to do the following:
pack :: [a] -> [(a, a)] pack [] = [] pack [_] = [] pack (x:y:xs) = (
I don't know if this is one line, but:
snd $ foldr (\ x (z, ps) -> maybe (Just x, ps) (\y -> (Nothing, (x, y) : ps) z) (Nothing, []) $ xs
should be the same as your function.