<div>Thanks you Ivan and David for clarifying this.</div>
<div> </div>
<div>Best Regards,</div>
<div> </div>
<div>Chris<br><br></div>
<div class="gmail_quote">On Sat, Sep 18, 2010 at 3:55 AM, Ivan Lazar Miljenovic <span dir="ltr">&lt;<a href="mailto:ivan.miljenovic@gmail.com">ivan.miljenovic@gmail.com</a>&gt;</span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>
<div></div>
<div class="h5">On 18 September 2010 17:51, Christopher Tauss &lt;<a href="mailto:ctauss1@gmail.com">ctauss1@gmail.com</a>&gt; wrote:<br>&gt; Hello Haskell Community -<br>&gt;<br>&gt; I am a professional programmer with 11 years experience, yet I just do not<br>
&gt; seem to be able to get the hang of even simple things in Haskell.  I am<br>&gt; trying to write a function that takes a list and returns the last n<br>&gt; elements.<br>&gt;<br>&gt; There may be a function which I can just call that does that, but I am<br>
&gt; trying to roll my own just to understand the concept.<br>&gt;<br>&gt; Let&#39;s call the function n_lastn and, given a list  [1,2,3,4,5], I would like<br>&gt; n_lastn 3 = [3,4,5]<br>&gt;<br>&gt; Seems like it would be something like:<br>
&gt;<br>&gt; n_lastn:: [a]-&gt;Int-&gt;[a]<br>&gt; n_lastn 1 (xs) = last(xs)<br>&gt; n_lastn n (x:xs) = ????<br>&gt;<br>&gt; The issue is I do not see how you can store the last elements of the list.<br><br></div></div>Easiest way I can think of:<br>
<br>n_lastn n = reverse . take n . reverse<br><br>Alternatively:<br><br>n_lastn n xs = drop (len - n) xs<br>   where<br>       len = length xs<br><font color="#888888"><br>--<br>Ivan Lazar Miljenovic<br><a href="mailto:Ivan.Miljenovic@gmail.com">Ivan.Miljenovic@gmail.com</a><br>
<a href="http://ivanmiljenovic.wordpress.com/" target="_blank">IvanMiljenovic.wordpress.com</a><br></font></blockquote></div><br>