In some languages, split-at is more performant than doing take and
drop separately. But in Clojure, split-at is simply defined as:
(defn split-at
"Returns a vector of [(take n coll) (drop n coll)]"
[n coll]
[(take n coll) (drop n coll)])
So by using split-at, you gain nothing other than the additional
overhead of constructing a vector and then turning around and
destructuring it.
On Wed, Apr 21, 2010 at 10:11 AM, Michał Marczyk
<[email protected]> wrote:
> One could also do
>
> (defn rotate [n s]
> (let [[front back] (split-at (mod n (count s)) s)]
> (concat back front)))
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en