Jump to content

Nao consigo resolver este problema


Recommended Posts

Com uma definição por compreensão defina a função scalarproduct :: [int] -> [int] -> Int que calcule o produto escalar de dois vectores x e y. Os vectores x e y são dados por listas de números.

> scalarproduct [1, 2, 3] [4, 5, 6]


apenas consigo fazer assim:

scalarproduct [] [] = 0

scalarproduct (x:xs) (y:ys) = x * y + scalarproduct xs ys

mas pedem com listas de compreensão, alguém dá uma ajudinha?

Link to comment
Share on other sites

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.