
9 Aug
2007
9 Aug
'07
8:38 a.m.
* Vimal wrote:
Beginning of CODE loop t function | t == 1 = do function | otherwise = do { function; loop (t - 1) function }
prod [] [] = 0 prod (a:as) (b:bs) = a*b + prod as bs
prod = sum . zipWith (*)
to_int :: [String] -> [Integer] to_int [] = [] to_int (x:xs) = (read x) : to_int xs
This is the slow part. Prelude.read ist really slow. Futhermore use the recusion pattern again: to_int = map read
doit = do n <- getLine a <- getLine b <- getLine let la = to_int (words a); lb = to_int (words b); in print (prod la lb)
What is n used for?