Yes, very nice. Thanks. Michael --- On Wed, 5/25/11, Henning Thielemann <schlepptop@henning-thielemann.de> wrote: From: Henning Thielemann <schlepptop@henning-thielemann.de> Subject: Re: [Haskell-cafe] Code critique - Was [Maybe Int] sans Nothings To: "michael rice" <nowgate@yahoo.com> Cc: "Haskell Cafe" <haskell-cafe@haskell.org> Date: Wednesday, May 25, 2011, 3:41 AM Alexander Solla schrieb:
buildMap :: GeneratorState1 (Map Prefix [String]) buildMap = do (mp,(pfx1,pfx2),words) <- get if (Prelude.null words) then {- No more words. Return final map (adding non_word for final prefix). -} return (insertWithKey' f (pfx1,pfx2) [non_word] mp) else do {- Add word to map at prefix & continue. -} put (insertWithKey' f (pfx1,pfx2) [head words] mp, (pfx2,(head words)), tail words) buildMap
I'm not a fan of explicit if-then-else's, but my preferred
case words of [] -> {- no more words -} ... w:ws -> ... would work perfectly.