[Haskell-beginners] Do I understand this well

Roelof Wobben rwobben at hotmail.com
Mon Jun 27 17:49:46 CEST 2011




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

  		 	   		  


More information about the Beginners mailing list