About
q1
divisors :: Int -> Int
divisors n = length [x | x <- [1..n], n mod
x == 0]
main = do
let n = 25
let num_divisors = divisors n
putStrLn $ "The number of divisors of " ++ show n ++ " is " ++ show num_divisors
q2 replaceThird :: [(String, String, String)] -> [Double] -> [(String, String, Double)] replaceThird [] [] = [] replaceThird ((x, y, _):xs) (d:ds) = (x, y, d) : replaceThird xs ds
main = do let lst1 = [("apple", "banana", "carrot"), ("dog", "cat", "fish"), ("red", "green", "blue")] let lst2 = [1.2, 3.4, 5.6] let replaced = replaceThird lst1 lst2 putStrLn $ "Original list: " ++ show lst1 putStrLn $ "Replaced list: " ++ show replaced