[Haskell-beginners] Re: Iterating through a list of char...
David Virebayre
dav.vire+haskell at gmail.com
Thu Apr 29 10:22:33 EDT 2010
On Thu, Apr 29, 2010 at 3:52 PM, jean verdier <verdier.jean at gmail.com> wrote:
> I may have missed it in this thread, but if not, why didn't anyone
> suggest:
>
> trans [] = []
> trans [x] = [x]
> trans ('a':_:xs) = 'a' : 'A' : trans xs
> trans (x:xs) = x : trans xs
While as a beginner (I still am !) I would come up with a solution
like this one, on the long run it helps trying to solve those problem
with maps, folds, filters, and zips: Eventually, you'll find the code
more readable, easier to write, and there's perhaps a better chance
that it can be optimised by ghc.
David.
More information about the Beginners
mailing list