
14 Sep
2011
14 Sep
'11
11:31 a.m.
On 15 September 2011 01:24, Sean Leather
On Wed, Sep 14, 2011 at 05:03, Kazu Yamamoto wrote:
I would like to have an efficient implementation of the chop function.
[...]
Are there any more efficient implementations of chop? Any suggestions?
chop xs = go xs id "" where go "" _ = id go (c:cs) ss | isSpace c = go cs (ss . (:) c) go (c:cs) ss | otherwise = ss . (:) c . go cs id
Why the extra case for go? The otherwise guard can be part of the second case... -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com