on master help sign in
Added string splitting.
commitcf5aaee05169c96f79b719a721af411edbb18449 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateFri 4 Dec 2009, 15:51 (17 years ago) parentd3ce014
1 file changed+10
src/Text/Hakyll/Util.hs+10
src/Text/Hakyll/Util.hs+10
@@ -8,6 +8,7 @@ import System.Directory
88import System.FilePath
99import Control.Monad
1010import Data.Char
11+import Data.List
1112
1213-- | Given a path to a file, try to make the path writable by making
1314-- all directories on the path.
@@ -34,3 +35,12 @@ getRecursiveContents topdir = do
3435trim :: String -> String
3536trim = reverse . trim' . reverse . trim'
3637 where trim' = dropWhile isSpace
38+
39+-- | Split a list at a certain element.
40+split :: (Eq a) => a -> [a] -> [[a]]
41+split element = unfoldr splitOnce
42+ where splitOnce l = let r = break (== element) l
43+ in case r of ([], []) -> Nothing
44+ (x, xs) -> if null xs
45+ then Just (x, [])
46+ else Just (x, tail xs)