forked from haskell-hvr/missingh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes.txt
27 lines (20 loc) · 825 Bytes
/
notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
basename p = reverse $ takeWhile (/= '/') $ reverse p
dirname p = case reverse $ dropWhile (/= '/') $ reverse p of
[] -> "."
p' -> p'
--------------------------------------------------
From: Mark Carroll <[email protected]>
Date: Sat, 15 Jan 2005 19:17:09 -0500 (EST)
To: John Goerzen <[email protected]>
Subject: Re: [Haskell-cafe] Re: Utility functions
You can take the original, or this version, as being Copyright (c) 2004
Mark Carroll under the modified BSD license. At the time of writing, it's
the one at http://www.opensource.org/licenses/bsd-license.php
splitListBy :: (a -> Bool) -> [a] -> [[a]]
splitListBy isElement =
unfoldr splitter . (ignored :)
where
splitter [] = Nothing
splitter xs = Just (span isElement (tail xs))
ignored = error "internal failure in splitListBy"
-- Mark