Find common directory path: Difference between revisions
→{{header|Haskell}}: Tidied 2nd version
(Add Rust implementation) |
(→{{header|Haskell}}: Tidied 2nd version) |
||
Line 932:
<lang haskell>import Data.List (transpose, intercalate)
import Data.List.Split (splitOn)
import Data.Bool (bool)
cdp :: [String] -> String
cdp
same (x:xs) = all (x ==) xs▼
▲ in intercalate "/" $
xs
▲ fmap head $ takeWhile same $ transpose (splitOn "/" <$> xs)
same
:: Eq a
=> [a] -> Bool
same [] = True
main :: IO ()
|