325H1 Could you please help me to solve this problem Write t

325H1) Could you please help me to solve this problem?

Write the following ML function:

Write a function which takes two integer list parameters and if they are of equal size, finds the product of all elements in both lists. Otherwise, the function should return 0.

Note: Write only one function.

Sample Run:

- mult([4,8,2],[1,2,5]); //Product of 4,8,2,1,2,5 is 640

val it = 640 : int

- mult([4,8],[1,2,5]);    //different lengths

val it = 0 : int

- mult([4,8,2,9],[1,2,5]); //different lengths

val it = 0 : int

Solution

public class multiply()

{

public static void multiplynumbers(int []x,int[]y)

{

product=1;

if(x.length==y.length)

{

for (int i=0;i<=x.length;i++)

{

}

return product;

else

return 0;

}

}

}

325H1) Could you please help me to solve this problem? Write the following ML function: Write a function which takes two integer list parameters and if they are

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site