Excalidraw Data

Text Elements

h) normaliza :: Polinomio -> Polinomio que dado um polinómio constrói um polinómio equivalente em que não podem aparecer vários monómios com o mesmo grau.

normaliza :: Polinomio Polinomio normaliza [] = [] normaliza ((c,g):t) = normalizaAux (c,g) (normaliza t)

normalizaAux :: Monomio Polinomio Polinomio normalizaAux m [] = [m] normalizaAux (cm,gm) ((c,g):t) | gm == g = (cm + c,g) : t | otherwise = (c,g) : normalizaAux (cm,gm) t

A fold takes a binary function, a starting value (I like to call it the accumulator) and a list to fold up. The binary function itself takes two parameters. The binary function is called with the accumulator and the first (or last) element and produces a new accumulator. Then, the binary function is called again with the new accumulator and the now new first (or last) element, and so on. Once we’ve walked over the whole list, only the accumulator remains, which is what we’ve reduced the list to. -Learn you a Haskell

sum’ :: (Num a) [a] a sum’ xs = foldl (\acc x acc + x) 0 xs

sum’ = foldl (+) 0

sum’ :: (Num a) [a] a

multMat m1 m2 = [dotProd linhaA colunaB | colunaB transpose’ m2, linhaA m1]

multMat m1 m2 = [ [ dotProd filaA colB | colB transpose m2 ] | filaA m1 ]

Matriz Resultado

Fila R-1: 11, 22

Fila R-2: 33, 44

El zipWith Exterior

zipWith f

zipWith f

Matriz B

Fila B-1: 10, 20

Fila B-2: 30, 40

Matriz A

Fila A-1: 1, 2

Fila A-2: 3, 4

Salida: Una Fila

11

22

El zipWith Interior: f = suma

Entrada: Dos Filas

1

2

10

20

triSup :: (Num a, Eq a) Mat a Bool triSup mat = all verificarFila (zip [0..] mat) where verificarFila (k, fila) = all (==0) (take k fila)

0CXRhr6v: AL_LCC_Matrizes-.pdf

6l204XXP: ficha6.pdf

cZHlyZ3K: ficha7.pdf

gP9t5eD4: ficha9.pdf

Embedded Files

2029774d3247780ad0f264391013fa732310f484: page=1

b4951c42d7d63a0cdb0744fdc28af9c734b51155: page=2

b07ed357fe64cf3173627b19798b45e8f2c34323: Pasted Image 20251231194848_632.png