Doubts about normalization of polynomials

Asked

Viewed 194 times

0

I set the function normalizes that given a polynomial, returns the corresponding polynomial, after normalization.

Example:

normaliza [(1,2),(3,4),(3,2)]

[(4,1),(3,4)]

type Polinomio = [Monomio]

type Monomio = (Float,Int)

normaliza :: Polinomio -> Polinomio

normaliza [(x,y)] = [(x,y)]

normaliza ((x,y): t) = (map (+) coeficientes (selgrau y  (x,y):t)) ((x,y) : t)

coeficientes :: [(Float,Int)] -> [Float]

coeficientes [(x,y)] = [x]

coeficientes (h:t) = fst h : coeficientes t

selgrau :: Int -> Polinomio -> Polinomio  

selgrau n [] = []

selgrau n l = filter f l   

            where f (c,e) = e == n 

I wonder if you could help me :)

  • But what’s your problem, anyway? Where do you think the mistake is?

  • It was in the definition of the function normaliza... I already found an alternative resolution

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.