-- 1) data Temp = C Float | F Float deCaF x = 9/5 * x + 32 instance Eq Temp where C x == C y = x == y F x == F y = x == y C x == F y = deCaF x == y F x == C y = C y == F x instance Show Temp where show (C x) = (show x)++"ºC" show (F x) = (show x)++"ºF" --2) union p lis1 lis2 = [(x,y,u,v) | (x,y) <-lis1, (u,v)<-lis2, p x u] --3) sumaAlt lis = foldr (+) 0 (zipWith (*) lis aux) where aux = 1: aux' aux'= (-1):aux -- 4) f :: Int -> [a] -> [[a]] f n = takeWhile (not . null) . map (take n) . iterate (drop n) -- Main> f 3 ”apabepacepa!” -- [”apa”,”bep”,”ace”,”pa!”] -- Main> f 2 [1,2,3,4,5] -- [[1,2],[3,4],[5]] -- 5) zs = [(1,1)]:(map f1 zs) where f1 ((x,y):[]) = [(x+1,y),(x,y+1)] f1 ((x,y):ps) = (x+1,y): f1 ps -- Los sucesivos elementos son: -- [(1, 1)] -- [(2, 1), (1, 2)] -- [(3, 1), (2, 2), (1, 3)] -- [(4, 1), (3, 2), (2, 3), (1, 4)] . . .