<div dir="ltr">On Wed, Apr 3, 2013 at 5:01 AM, Angus Comber <span dir="ltr">&lt;<a href="mailto:anguscomber@gmail.com" target="_blank">anguscomber@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>In the (x:xs) : just delimits each element. so x is the first element. Why can I not print by using x?</div><div><br></div><div>Also xs is of what type? list of values? So does this mean x is an element and xs must be of type list? Confused...</div>
</div></blockquote><div><br></div><div>Actually, you just answered yourself. x is an element, xs is a list. (++) combines lists, so to insert your element using (++) you need to make it a list. [x] is a list containing your element x and nothing else.</div>
<div><br></div><div>Another way to do it is to do the same as the pattern match, but in this case that&#39;s kinda ugly:</div><div><br></div><div>    <span style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12px">firstLetter all@(x:xs) = &quot;The first letter of &quot; ++ all ++ &quot; is &quot; ++ (x : &quot; otherbit &quot;) ++ xs</span></div>
<div><br></div><div>or</div><div><div><br></div><div>    <span style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12px">firstLetter all@(x:xs) = &quot;The first letter of &quot; ++ all ++ &quot; is &quot; ++ (x : []) ++ &quot; otherbit &quot; ++ xs</span></div>
</div><div><span style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12px"><br></span></div><div>(note that &quot;is of type list&quot; is incomplete; list of *what*? In this case, list of Char. Haskell String is just [Char] (list of Char), which is highly convenient but a bit slow in real programs that manipulate a lot of String-s.)</div>
<div><br></div></div>-- <br><div dir="ltr"><div>brandon s allbery kf8nh                               sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>                                  <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div>
<div>unix, openafs, kerberos, infrastructure, xmonad        <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div>
</div>