Concat
(defn rotate [a n]
(let [l (count a)
off (-> (mod n l) (+ (mod n l) l) l)]
(concat (drop off a) (take off a))))
(rotate '((1 2) (3 4) (5 6) (7 8) (9 10)) 3)
=> ((7 8) (9 10) (1 2) (3 4) (5 6))
On Saturday, March 23, 2019 at 6:01:55 AM UTC-6, Matching Socks wrote:
>
> Could it finish off the result in some way other than flatten? flatten
> would go too far if the input data were a collection of collections.
>
> Indeed, I would support adding (some form of) rotate to the standard
> library *on the condition that flatten be removed.* rotate is an
> amusement, but flatten is unexploded ordnance.
>
--
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
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.