
15 Feb
2007
15 Feb
'07
5:30 p.m.
On 2/15/07, Gene A
Haskell solution: build the array of all lower case with corresponding numbers starting with 1
Prelude> let lowerCaseTable = zip ['a'..'z'] [1..26]
A couple of functions: Prelude> let box a = a:[] Prelude> let formatTableItems (a,b) = (box a) ++ " = " ++ (show b) ++ "\n"
Then to output the results: putStrLn $ foldr (++) "\n"$ map formatTableItems lowerCaseTable a = 1 b = 2
That last output function group could have been simpler.. I sometimes forget concatMap.. as I did there it should have been: Prelude> putStrLn $ concatMap formatTableItems lowerCaseTable a = 1 b = 2 c = 3 etc.... even simpler than the first.. where I used map and then foldr cheers, gene