[Haskell-beginners] Simplifying code
edgar klerks
edgar.klerks at gmail.com
Wed Feb 10 06:48:07 EST 2010
I found out I get the posts in my mail and I am clicking in the mailinglist.
Therefore I am starting new threads over and over again. My apologies.
>Why add the extra tuple?
>Better: Chain Char WordTree
It feels a bit too loose. Think it is a imperative quirk. I remove the
tupples.
And I am going to change the type Rule to a Map. I have used that package
before and it is fast
and easy to use.
Another question. I have a book Real World Haskell, which is great, but I
would like to read somewhat more indepth
stuff. Can you recommend one?
Thanks for your advice.
With kind regards,
Edgar
I switched to evolution. Hopefully it will take the in reply to field.
On Tue, Feb 9, 2010 at 11:07 PM, Patrick LeBoutillier <
patrick.leboutillier at gmail.com> wrote:
> Daniel,
>
> > Sure. If you don't mind that the mutations come in a different order, one
> > thing that works wonders is "sequence",
> >
> > sequence :: Monad m => [m a] -> m [a]
> >
> > In particular, for m = [], sequence :: [[a]] -> [[a]]. Then, knowing what
> > sequence does, we can write
> >
> > import Control.Monad (sequence)
> >
> > generateAll :: String -> [String]
> > generateAll word = sequence (map f word)
> > where
> > f c = case lookup c leat of
> > Just r -> [c,r]
> > Nothing -> [c]
>
> That's very nice!
>
> One question though: In the docs sequence is described as:
>
> "Evaluate each action in the sequence from left to right, and
> collect the results."
>
> How is one supposed to deduce what the behavior will be for the list
> monad (besides looking at the source)?
>
>
> Patrick
>
> --
> =====================
> Patrick LeBoutillier
> Rosemère, Québec, Canada
>
--
Flatliner ICT Service,
Email: Edgar.klerks at gmail.com,
Tel: +31727851429
Fax: +31848363080
Skype: edgar.klerks
Website: flatlinerict.nl
Adres: Koelmalaan 258,
1813JD, Alkmaar
Nederland
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100210/816852b9/attachment-0001.html
More information about the Beginners
mailing list