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
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
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
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