Testing with this, gives the wrong result
(rotate 6 [1 2 3 4 5]) Expected Output: [2 3 4 5 1] Actual Output: [1 2 3 4 
5] 


On Wednesday, 21 April 2010 21:07:40 UTC+5:30, Michał Marczyk wrote:
>
> On 21 April 2010 17:23, Sean Devlin <francoi...@gmail.com <javascript:>> 
> wrote: 
> > I've had to code these guys up a few times: 
>
> Nice functions! 
>
> I'd replace "collection" with "sequence" in the docstrings, though. 
> (And rename the args accordingly.) 
>
> You can also rewrite rotate as 
>
> (defn rotate [n s] 
>   (lazy-cat (drop n s) 
>             (take n s))) 
>
> which has the built-in assumption that n doesn't exceed the length of 
> s, but won't force more than (inc n) elements of s before producing 
> the first item of the result. (Additional forcing might happen due to 
> chunking issues, of course.) 
>
> As a final remark, I believe that rotate takes constant time to 
> execute, followed by O(n) time to produce the first element. This is 
> petty nitpicking, of course. ;-) 
>
> Sincerely, 
> Michał 
>
> -- 
> You received this message because you are subscribed to the Google 
> Groups "Clojure" group. 
> To post to this group, send email to clo...@googlegroups.com <javascript:> 
> Note that posts from new members are moderated - please be patient with 
> your first post. 
> To unsubscribe from this group, send email to 
> clo...@googlegroups.com <javascript:> 
> 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 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/ce8e19a1-c539-4548-ad16-a3c449d8b5ee%40googlegroups.com.

Reply via email to