Re: what did I do wrong here ?
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <[email protected]> |
Le 14/10/2014 18:33, Roelof Wobben [email protected] [ocaml_beginners] a écrit : > let rec sum a = if a = 0 then a = a + 0 else a = a + sum (a - 1) ;; The two branches of your if structure are tests : * |a = a + 0| which is |true| * and |a = a + sum (a - 1)| So. |sum| should return a |bool|, right ? But in the same time, you are using |sum| as if it would return an int, since you add |sum(a - 1) to|a|with the|+` function that takes to ints and returns an int. Just get rid of the |a =|: the result of the function is either the true branch of the if test, or the false branch. Hoping this will help. -- Matthieu Dubuget Guide d’autodéfense numérique : http://guide.boum.org