You could use (-1)^{i+1}, which would be a bit more mathy but it may not be efficient.
(defn altsum [n] (->> (range 1 (inc n)) (map #(* % (Math/pow -1 (inc %)))) (reduce +))) On Nov 13, 2014, at 6:31 PM, Andy L <core.as...@gmail.com> wrote: > Hi, > > All I was able to come up with was this > > (defn altsum[n] (reduce + (map * (range 1 (inc n)) (interpose -1 (repeat > 1))))) > > ... works quite well, however I was wondering if there is more idiomatic way > to write that. > > Thanks, > Andy > > -- > 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. -- 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.