[Haskell-beginners] function defenition. Do I understand it right?

Roelof Wobben rwobben at hotmail.com
Mon Jul 11 16:48:26 CEST 2011


Hello, 

I have made a exercise where I must split a even list.
The answer is :

halve xs = (take n xs  drop n xs) 
     where n = length xs 'div' 2 

Now I want to change it so i can split even and not even list,.
I thought this can be the answer 

halve xs = 
         lenght xs 'mod' 2 = 0  : (take n  xs   drop n xs) 
         otherwise :  (take n+1 xs  drop n+1 xs) 
         where 
             n = length xs 'div' 2 


Can this be working ?
I did not check this on GCHI because Im  re - installing my OS.

Regards. 

Roelof

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110711/d5ab7dc4/attachment.htm>


More information about the Beginners mailing list