On Wed, Sep 14, 2011 at 17:31, Ivan Lazar Miljenovic wrote:
On 15 September 2011 01:24, Sean Leather wrote:
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
On Sep 14, 2011, at 5:29 AM, Kazu Yamamoto (山本和彦) wrote:
Hello,
Of course, I use ByteString or Text for real programming. But I would
like to know whether or not there are any efficient methods to remove
a tail part of a list.
--Kazu
In that case, I would prefer this version, since it
Hello,
My friend reached the following version:
chop :: String - String
chop = foldr go []
where
go x xs
| isSpace x null xs = []
| otherwise= x:xs
This version is faster than the reverse version in most cases. The
point is checking isSpace first and falling into
* Kazu Yamamoto k...@iij.ad.jp [2011-09-14 15:59:05+0900]
Hello,
My friend reached the following version:
chop :: String - String
chop = foldr go []
where
go x xs
| isSpace x null xs = []
| otherwise= x:xs
This version is faster than the reverse
You can find the results of my friend:
https://gist.github.com/1215660
Please ignore the Japanese text. Please read the code and the results.
I'm not sure why you had the different result.
--Kazu
This was exactly my first attempt on rewriting your foldr version.
Unfortunately, it
On Wednesday 14 September 2011, 09:17:16, Kazu Yamamoto wrote:
You can find the results of my friend:
https://gist.github.com/1215660
Please ignore the Japanese text. Please read the code and the results.
I'm not sure why you had the different result.
Input size. The lazy foldr
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 |
On 15 September 2011 01:24, Sean Leather leat...@cs.uu.nl wrote:
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
Quoth Ivan Lazar Miljenovic ivan.miljeno...@gmail.com,
Why the extra case for go? The otherwise guard can be part of the
second case...
I noticed that myself, so I thought let's see if it's just a matter of
style that comes out the same after compilation ...
... and after a few minutes
On 9/13/11 11:03 PM, Kazu Yamamoto (山本和彦) wrote:
Hello Cafe,
I would like to have an efficient implementation of the chop function.
As you guess, the chop function drops spaces in the tail of a list.
chop foo bar baz
- foo bar baz
A naive implementation is as follows:
Hello Cafe,
I would like to have an efficient implementation of the chop function.
As you guess, the chop function drops spaces in the tail of a list.
chop foo bar baz
-foo bar baz
A naive implementation is as follows:
chopReverse :: String - String
chopReverse =
This was a recent question on StackOverflow:
http://stackoverflow.com/questions/6270324/in-haskell-how-do-you-trim-whitespace-from-the-beginning-and-end-of-a-string/6270382#6270382
Where I started:
If you have serious text processing needs then use the text package
from hackage.
And concluded:
Hello,
Of course, I use ByteString or Text for real programming. But I would
like to know whether or not there are any efficient methods to remove
a tail part of a list.
--Kazu
From: Thomas DuBuisson thomas.dubuis...@gmail.com
Subject: Re: [Haskell-cafe] efficient chop
This was a recent
On 14 September 2011 13:29, Kazu Yamamoto k...@iij.ad.jp wrote:
Hello,
Of course, I use ByteString or Text for real programming. But I would
like to know whether or not there are any efficient methods to remove
a tail part of a list.
I doubt it; lists aren't that great a data type if you
14 matches
Mail list logo