haskell - Stuck in recursion in rangeProduct function -


I am starting in Haskell and I am stuck in a simple recurrence function.

I'm trying to define a function range for the product that is given when natural number is given and n product

m * (m + 1) ... (n-1) * n

should return the function when n is smaller than meter

Whatever I have tried:

  rangeProduct :: int - & gt; Int - & gt; Int Range Product m n | M & gt; N = 0 | Otherwise = M * N * Category Product (M + 1) (N-1)  

But this is incorrect because in another protector, when the meter grows up and at some point , Will get bigger than zero and it will get zero, which is how much it has done to multiply zero, resulting in the function of 0 every time I will run.

I know the answer is simple but I'm stuck. Can anyone help? Thanks!

Why is the growth and decrease at the same time? Just go in one direction:

  Category Product m n | M & gt; N = 0 | I == N = N | Otherwise = M * Category Product (M + 1) n  

Although you can not easily define it

  rangeProduct :: Integer - & gt; ; Integer - & gt; Integer category product m n | | M & gt; N = 0 | Otherwise = product [m ... n]  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -