Ejercicio 7 Practico 2

Re: Ejercicio 7 Practico 2

de Marcos Viera - InCo -
Número de respuestas: 0
Podés ver a zipWith de esta forma:
- dado zipWith f [x1,..,xn] [y1,..,yn]
- resulta en [f x1 y1, ..., f xn yn]
Por lo que:
zipWith (.) [length, sum] [drop 4, take 4] = [(.) length (drop 4), (.) sum (take 4)] = [length . drop 4, sum . take 4]

Ahora, si querés ver esta definición de zipWith:
- zipWith f xs ys = map (uncurry f) (zip xs ys)

tenés
zipWith (.) [length, sum] [drop 4, take 4]
= map (uncurry (.)) (zip [length, sum] [drop 4, take 4])
= map (uncurry (.)) [(length, drop 4), (sum, take 4)]
= [uncurry (.) (length, drop 4), uncurry (.) (sum, take 4)] -- dada la definición de map
= [length . drop 4, sum . take 4] -- dada la definición de uncurry (uncurry f (x,y) = f x y)

saludos