[Haskell-beginners] function defenition. Do I understand it right?
Benjamin Edwards
edwards.benj at gmail.com
Tue Jul 12 11:34:25 CEST 2011
I don't even understand what you are trying to do :)
if you want to pattern match on the empty list
foo :: [a] -> [a]
foo [] = 0
foo (x:xs) = undefined
if you want to use the guard syntax
foo xs | null xs = 0
| otherwise = undefined
Ben
On 12 July 2011 10:02, Roelof Wobben <rwobben at hotmail.com> wrote:
>
>
>
> hello
>
>
>
> Everyone thanks for the help.
>
> I'm now trying to make this work on a empty list.
>
>
>
> But my question is.
>
> When the definition is :
>
>
>
> [a] -> [a] [a]
>
>
>
> Is it correct that I don't can use.
>
>
>
> length xs = 0 | []
>
>
>
> Roelof
>
> ----------------------------------------
> > Subject: Re: [Haskell-beginners] function defenition. Do I understand it
> right?
> > From: d at vidplace.com
> > Date: Mon, 11 Jul 2011 18:56:42 -0400
> > CC: beginners at haskell.org
> > To: rwobben at hotmail.com
> >
> > On Jul 11, 2011, at 5:13 PM, Roelof Wobben wrote:
> >
> > > What I try to achieve is this:
> > >
> > >
> > >
> > > [1,2,3,4] will be [1,2] [3,4]
> > >
> > > [1,2,3,4,5] will be [1,2,3] [3,4,5]
> >
> > So, I think what you want is this http://codepad.org/kjpbtLfR
> >
> > Is that correct?
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110712/3357faf8/attachment.htm>
More information about the Beginners
mailing list