On 2/15/07, Gene A <[EMAIL PROTECTED]> wrote:
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
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe