<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
<br>&nbsp;Oke, <BR>&nbsp;<BR>Now figure out how I can find the 3 in the list [1,2,3,4]<BR>&nbsp;<BR>I was thinking about using tail [1,2,3,4] and after that use last [1,2,3]<BR>&nbsp;<BR>So something like last [ tail [1,2,3,4]<BR>&nbsp;<BR>Or :<BR>&nbsp;<BR>let outcome = tail [1,2,3,4]<BR>let outcome2 = last [outcome]<BR>&nbsp;<BR>Roelof<BR>&nbsp;<BR><div>Date: Mon, 27 Jun 2011 15:20:18 +0300<br>From: mats.rauhala@gmail.com<br>To: beginners@haskell.org<br>Subject: Re: [Haskell-beginners] first number is a list<br><br><pre>On 12:08 Mon 27 Jun     , Roelof Wobben wrote:<br>&gt;  Sorry,  Now Im missing you. First you talked about head[x:-] = x and now head [1,2,3,4] is good. Roelof  Date: Mon, 27 Jun 2011 15:03:00 +0300<br> <br>I wasn't entirely clear. The function declaration for head is:<br> <br> head (x:_) = x<br> head _ = error "No elements"<br> <br>or something similar. You can see from this that it uses pattern<br>matching to find the first element (x:_). _ means that the value is<br>disgarded. [1,2,3,4] is just syntactic sugar for 1 : 2 : 3 : 4 : [], so<br>pattern matching (x:_) finds 1 from the previous list.<br> <br>You use the function head like I mentioned in the last email; `head<br>[1,2,3,4]`. Try firing up ghci and inputting that in it.<br> <br> <br>-- <br>Mats Rauhala<br>MasseR<br></pre><br>_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners</div>                                               </div></body>
</html>