
25 May
2011
25 May
'11
3:41 a.m.
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.