[Haskell-beginners] Review request
C K Kashyap
ckkashyap at gmail.com
Sun Jul 15 14:08:29 CEST 2012
Hi,
I've written a small haskell program to extract a section from a file
between start and end markers. For example, if I have a file such as below
-
a
b
c
<bug>
d
e
f
</bug>
g
h
i
I'd like to extract the contents between <bug> and </bug> (including the
markers).
startTag = "<bug>"endTag = "</bug>"
process = unlines . specialTakeWhile (f endTag) . dropWhile (f
startTag) . lines
where f t x = not (x =~ t)
specialTakeWhile :: (a -> Bool) -> [a] -> [a]
specialTakeWhile ff [] = []
specialTakeWhile ff (x:xs) = if ff x then
x:(specialTakeWhile ff xs) else [x]
It'll be great if I could get some feedback on this.
Regards,
Kashyap
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120715/77950c5b/attachment.htm>
More information about the Beginners
mailing list