let cond (a,b,c) = match a with | true -> t | false -> e
let rec fact n = cond (n=0,1, n * fact (n-1))
let rec fact n = if n=0 then 1 else n * fact (n-1)
in the above code segments, the first version gives a stack overflow exception while the second one works fine. what is the difference between these two? they seem to function the same but apparently don't.
Aucun commentaire:
Enregistrer un commentaire