Revision 748d5d50
b/Ganeti/HTools/Utils.hs | ||
---|---|---|
73 | 73 |
commaJoin :: [String] -> String |
74 | 74 |
commaJoin = intercalate "," |
75 | 75 |
|
76 |
-- | Split a string on a separator and return an array.
|
|
77 |
sepSplit :: Char -> String -> [String]
|
|
76 |
-- | Split a list on a separator and return an array.
|
|
77 |
sepSplit :: Eq a => a -> [a] -> [[a]]
|
|
78 | 78 |
sepSplit sep s |
79 |
| x == "" && xs == [] = []
|
|
80 |
| xs == [] = [x]
|
|
81 |
| ys == [] = [x,""]
|
|
82 |
| otherwise = x:sepSplit sep ys
|
|
79 |
| null s = []
|
|
80 |
| null xs = [x]
|
|
81 |
| null ys = [x,[]]
|
|
82 |
| otherwise = x:sepSplit sep ys |
|
83 | 83 |
where (x, xs) = break (== sep) s |
84 | 84 |
ys = drop 1 xs |
85 | 85 |
|
Also available in: Unified diff