genesis001 Posted January 8, 2010 at 05:47 AM Report Share #304724 Posted January 8, 2010 at 05:47 AM Boas, queria saber se alguém me consegue esclarecer o seguinte: quando utilizamos a expressão where, a ordem das equações que a seguem importa, certo? Como é que sabemos essa ordem? Exemplificando: Se introduzir a seguinte função num script e em seguida abrir o ficheiro .hs não há problemas: testa y = f b + f y + f a + 3 where (a,😕 = (3*c, f 2) c = 10 f x = x + 7*c mas se trocar a ordem das equações: testa y = f b + f y + f a + 3 where (a,😁 = (3*c, f 2) f x = x + 7*c c = 10 aparece o seguinte erro: parse error on input '=' Não consigo determinar qual é que tem que ser a ordem das equações para que não apareça o erro... Por exemplo na seguinte função acontece-me o mesmo: nraizes :: Double->Double->Double->Double nraizes a b c | d < 0 = 0 | d > 0 = 2 | d == 0 = 1 where d = b^2 - 4*a*c raizes :: Double->Double->Double->[Double] raizes a b c | (nraizes a b c == 2) = [r1,r2] where r1 = (-b + r)/(2*a) r2 = (-b - r)/(2*a) r = sqrt d d = b^2 - 4*a*c | nraizes a b c == 0 = [error "raizes imaginarias"] | nraizes a b c == 1 = (-b / (2*a)):[] E alguém consegue explicar-me como é que se instala um cabal? Agradeço a ajuda Link to comment Share on other sites More sharing options...
genesis001 Posted January 12, 2010 at 04:05 PM Author Report Share #305689 Posted January 12, 2010 at 04:05 PM alguém? Link to comment Share on other sites More sharing options...
Baderous Posted January 12, 2010 at 04:31 PM Report Share #305696 Posted January 12, 2010 at 04:31 PM A ordem não importa, o que tu tens são problemas de indentação. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now