Jump to content

Recommended Posts

Posted
numeroraizes :: Float -> Float -> Float -> Float
numeroraizes a b c | delta < 0 = 0
                  | delta == 0 = 1
                  | otherwise = 2
                  where delta = b^2 - 4 * a * c

Após fazer esta função que calcula o número de raízes de um polinómio de 2º grau fiz a seguinte para calcular a lista das raízes:

formularesolvente :: Float -> Float -> Float -> [Float]
formularesolvente a b c | numeroraizes == 0 = []
                       | numeroraizes == 1 = [-b / (2 * a)]
                       | numeroraizes == 2 = [-b + sqrt (b^2 - 4 * a * c) / (2 * a)] && [-b - sqrt (b^2 - 4 * a * c) / (2 * a)]

A resposta de erro foi: not in scope: 'numeroraizes'.

Agradecia a quem me pudesse dar uma ajudinha (:

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.