[Haskell-beginners] Do I understand this well

Roelof Wobben rwobben at hotmail.com
Mon Jun 27 18:52:10 CEST 2011


Oke

 

It worked now.

A bumpy ride to begin something new with.

 

Roelof



----------------------------------------
> From: maydwell at gmail.com
> Date: Mon, 27 Jun 2011 23:51:45 +0800
> Subject: Re: [Haskell-beginners] Do I understand this well
> To: rwobben at hotmail.com
> CC: beginners at haskell.org
>
> Top-level bindings are done in ghci with let:
>
> let (x, y) = addVectors (3.0, 4.5, -3.4, -5.6)
>
> On Mon, Jun 27, 2011 at 11:49 PM, Roelof Wobben <rwobben at hotmail.com> wrote:
> >
> >
> >
> > ________________________________
> >> Date: Mon, 27 Jun 2011 16:14:28 +0100
> >> Subject: Re: [Haskell-beginners] Do I understand this well
> >> From: colinpauladams at gmail.com
> >> To: rwobben at hotmail.com
> >>
> >> No.
> >>
> >> You are onfusing defining a function with using it.
> >>
> >>
> >> addVectors (x1, y1) (x2, y2) = (x1 + x2, y1 + y2)
> >>
> >> defines the function addVectors
> >>
> >> (x, y) = addVectors (3.0, 4.5, -3.4, -5.6)
> >>
> >> calls the function, and binds x and y to the components of the result
> >> (pattern matching).
> >>
> >> Alternatively:
> >>
> >> fst . addVectors (3.0, 4.5, -3.4, -5.6)
> >>
> >> will return the x-compnent of the result (by composing functions)
> >>
> >
> >
> > Oke,
> >
> >
> >
> > I understand that I think
> >
> > But when I ghci I enter :
> >
> >
> > (x, y) = addVectors (3.0, 4.5, -3.4, -5.6)
> >
> >
> >
> >
> >
> > after I made a file with the file defenition.
> >
> > I get this error :
> >
> >
> >
> > :1:7 parse error on input =
> >
> >
> >
> > So something is not right here.
> >
> >
> >
> > Roelof
> >
> >
> > _______________________________________________
> > Beginners mailing list
> > Beginners at haskell.org
> > http://www.haskell.org/mailman/listinfo/beginners
> > 		 	   		  


More information about the Beginners mailing list