RE: [Haskell-cafe] Pattern matching on numbers?

2008-11-19 Thread Tobias Bexelius
Cafe Subject: Re: [Haskell-cafe] Pattern matching on numbers? On Tue, Nov 18, 2008 at 6:56 PM, Henning Thielemann [EMAIL PROTECTED] wrote: On Tue, 18 Nov 2008, Ryan Ingram wrote: How does this work? fac n = case n of 0 - 1 _ - n * fac (n-1) ghci :t fac fac :: (Num t) = t - t

[Haskell-cafe] Pattern matching on numbers?

2008-11-18 Thread Ryan Ingram
How does this work? fac n = case n of 0 - 1 _ - n * fac (n-1) ghci :t fac fac :: (Num t) = t - t The first line of fac pattern matches on 0. So how does this work over any value of the Num typeclass? I know that the 1 on the rhs of fac are replaced with (fromInteger 1), but what

Re: [Haskell-cafe] Pattern matching on numbers?

2008-11-18 Thread Henning Thielemann
On Tue, 18 Nov 2008, Ryan Ingram wrote: How does this work? fac n = case n of 0 - 1 _ - n * fac (n-1) ghci :t fac fac :: (Num t) = t - t The first line of fac pattern matches on 0. So how does this work over any value of the Num typeclass? I know that the 1 on the rhs of fac are

Re: [Haskell-cafe] Pattern matching on numbers?

2008-11-18 Thread David Menendez
On Tue, Nov 18, 2008 at 6:56 PM, Henning Thielemann [EMAIL PROTECTED] wrote: On Tue, 18 Nov 2008, Ryan Ingram wrote: How does this work? fac n = case n of 0 - 1 _ - n * fac (n-1) ghci :t fac fac :: (Num t) = t - t The first line of fac pattern matches on 0. So how does this work