
6 Jun
2013
6 Jun
'13
7:06 p.m.
On 7 June 2013 00:36, Costello, Roger L.
Hi Folks,
I have a string that contains a person's name. [snip] Here is an example string:
s = " \" John Doe \" "
After processing, I should have:
John Doe
Below is my implementation. Is there is a shorter and more efficient implementation? [snip code]
How about this? import Data.Char import Control.Monad.Reader isAlphaOrSpace = liftM2 (||) isAlpha isSpace -- alternatively, -- isAlphaOrSpace x = isAlpha x || isSpace x -- if you find this more readable s = " \" John Doe \" " fs = unwords . words . takeWhile isAlphaOrSpace . dropWhile (not . isAlpha) $ s -- Denis Kasak