I am trying to make a function in OCaml that performs the function of summing in math. I tried this:
sum nmf = if n = 0 then 0 else if n > m then f else f + sum (n + 1) mf;;
However, I get an error message - "Characters 41-44: else f * sum (n + 1) mf ;; Error: the sum of the unrelated value and the sum is underlined (has pointers to carrots pointing to it)
I looked at this: OCaml Simple Actions This is the same question, but I see many other things that I donβt have. For example, for my n = m case, I don't have fn, and then otherwise I don't have f m.
Why do you need fn if you want the function to return an integer? D: What is the problem !? Thanks in advance.
source share