root / notes.txt

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