[Haskell-cafe] partially indeterminate?
christopher.howard at frigidcode.com
Tue Jul 16 01:39:40 CEST 2013
Hi. For learning, I was doing the "phone words" problem, where a
function translates the digits of a phone number into all possible
words. I am trying to connect this idea to the idea of list
comprehensions / list monads (sort of the same thing, yes?)
I know it is easy to do this:
w = do two <- "ABC"
three <- "DEF"
four <- "GHI"
-- and the other digits
[[two, three, two, four]] -- for example
But what if you don't know in advance what the digits will be? I'm not
sure how to insert that deterministic component into this idea. So far,
I have a framework like so:
p dx = do undefined
where m = map (\d -> case d of
2 -> "ABC"
3 -> "DEF"
4 -> "GHI"
5 -> "JKL"
6 -> "MNO"
7 -> "PRS"
8 -> "TUV"
9 -> "WXY"
otherwise -> show d) dx
I would appreciate any guidance.
More information about the Haskell-Cafe