One way: user=>(concat (range 5) (range 5 0 -1)) (0 1 2 3 4 5 4 3 2 1)
user=>(take 15 (cycle (concat (range 5) (range 5 0 -1))))) (0 1 2 3 4 5 4 3 2 1 0 1 2 3 4) On Wed, Aug 24, 2011 at 6:49 PM, HiHeelHottie <[email protected]>wrote: > > How can you generate a sequence of numbers from 0 to n and back? Here > is my try. > > user> (require '(clojure.contrib [math :as math])) > nil > user> (take 15 (let [n 3] (drop n (map #(math/abs (- (mod % (* n 2)) > n)) (range))))) > (0 1 2 3 2 1 0 1 2 3 2 1 0 1 2) > > -- > 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 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
