| 1 |
249dd575 |
John |
basename p = reverse $ takeWhile (/= '/') $ reverse p
|
| 2 |
249dd575 |
John |
|
| 3 |
249dd575 |
John |
dirname p = case reverse $ dropWhile (/= '/') $ reverse p of
|
| 4 |
249dd575 |
John |
[] -> "."
|
| 5 |
249dd575 |
John |
p' -> p'
|
| 6 |
c11baa18 |
John |
|
| 7 |
c11baa18 |
John |
--------------------------------------------------
|
| 8 |
c11baa18 |
John |
|
| 9 |
c11baa18 |
John |
From: Mark Carroll <mark@ixod.org>
|
| 10 |
c11baa18 |
John |
Date: Sat, 15 Jan 2005 19:17:09 -0500 (EST)
|
| 11 |
c11baa18 |
John |
To: John Goerzen <jgoerzen@complete.org>
|
| 12 |
c11baa18 |
John |
Subject: Re: [Haskell-cafe] Re: Utility functions
|
| 13 |
c11baa18 |
John |
|
| 14 |
c11baa18 |
John |
You can take the original, or this version, as being Copyright (c) 2004
|
| 15 |
c11baa18 |
John |
Mark Carroll under the modified BSD license. At the time of writing, it's
|
| 16 |
c11baa18 |
John |
the one at http://www.opensource.org/licenses/bsd-license.php
|
| 17 |
c11baa18 |
John |
|
| 18 |
c11baa18 |
John |
splitListBy :: (a -> Bool) -> [a] -> [[a]]
|
| 19 |
c11baa18 |
John |
|
| 20 |
c11baa18 |
John |
splitListBy isElement =
|
| 21 |
c11baa18 |
John |
unfoldr splitter . (ignored :)
|
| 22 |
c11baa18 |
John |
where
|
| 23 |
c11baa18 |
John |
splitter [] = Nothing
|
| 24 |
c11baa18 |
John |
splitter xs = Just (span isElement (tail xs))
|
| 25 |
c11baa18 |
John |
ignored = error "internal failure in splitListBy"
|
| 26 |
c11baa18 |
John |
|
| 27 |
c11baa18 |
John |
-- Mark |