[Haskell-beginners] first number is a list

Roelof Wobben rwobben at hotmail.com
Mon Jun 27 13:55:37 CEST 2011


Oke, 
I'm not sure I understand you right. Let's say I have this list [1,2,3,4]How must I use head now ? Roelof Date: Mon, 27 Jun 2011 14:50:14 +0300
From: mats.rauhala at gmail.com
To: beginners at haskell.org
Subject: Re: [Haskell-beginners] first number is a list

I'm sorry, I'm not entirely sure what you're trying to do. Are you
trying to find the first number _in_ a list? That could be done with for
example pattern matching:
 
 head (x:_) = x
 head _ = error "Empty list"
 
The guards in list comprehension requires booleans, you gave it a
function that takes a list and returns an item of the same time.
 
 last :: [a] -> a
 
 
-- 
Mats Rauhala
MasseR

_______________________________________________
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/20110627/87511d51/attachment.htm>


More information about the Beginners mailing list