
On Thu, 01 Aug 2013 17:09:11 +0200, Gesh hseG
On Wed, Jul 24, 2013 at 4:18 PM, Henk-Jan van Tuyl
wrote: d="12345" f s = unwords $ map (\c -> let (Just x) = lookup c ((' ',"") : ('J',"24") : zip (['A'..'I'] ++ ['K'..'Z']) [y : [x] | y <- d, x <- d]) in x) s main = getLine >> (interact $ unlines . map f . lines)
Note that you can point-freeify that solution a little and sacrifice totality, yielding an even shorter solution. (I didn't remove the lambda expression, as it ends up being shorter than flipping lookup) Inline the definitions and remove redundant spaces and newlines in the code below: d = "12345" f = unwords . map $ \c -> fromJust $ lookup c ((' ',"") : ('J',"24") : zip (['A'..'Z']\\"J") [[y,x] | y <- d, x <- d]) main = interact $ unlines . map f . drop 1 . lines
There are imports necessary for fromJust and \\, this makes it longer again. Regards, Henk-Jan van Tuyl -- Folding@home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://folding.stanford.edu/ http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming --