On Thursday 02 September 2010 14:49:12, Eoin C. Bairéad wrote: > Example 2 > > Prelude> let fac n = if n == 0 then 1 else n * fac (n-1) > > How does it know to stop ?
It tests for n == 0. If that returns True, the recursion stops. > and why does fac 2.5 hang? > Because 2.5 is not an integer, so fac gets called with 2.5 1.5 0.5 -0.5 -1.5 -2.5 ... but never with 0, so you get infinite recursion. _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
