[Haskell-beginners] first number is a list

Mats Rauhala mats.rauhala at gmail.com
Mon Jun 27 13:50:14 CEST 2011


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110627/865d3ba3/attachment.pgp>


More information about the Beginners mailing list