On 30 April 2014 11:41, Roelof Wobben <rwob...@hotmail.com> wrote:
>
>
> Op woensdag 30 april 2014 12:14:39 UTC+2 schreef James Reeves:
>>
>>
>> Consider how you might add a counter to the loop. You'll want to
>> increment the counter, then stop when it reaches the desired number.
>>
>
>
> So without checking it so out of my head I would do this
>
>  (defn last* [coll, number]
>    (loop [coll coll]
>      (if == counter number))
>        (first coll)
>        (recur (next coll) (+counter 1 ))
>

Essentially yes. You need to initiate the counter to zero, and you still
need a condition to make sure you don't go past the end of the seq (in case
n is more than the length of the list), but you've basically got it.

- James

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to