On 16 July 2010 20:57, Isaac Hodes <iho...@mac.com> wrote: > I am trying to create a lazy/functional/efficient/Clojuresque function > to carry out convolution on two lists/vectors of (ideally BigDecimals > but that may be inefficient) doubles.
Perhaps something like this? (defn convolve [ns ms] (loop [nums (for [[i n] (indexed ns) [j m] (indexed ms)] [(+ i j) (+ n m)]) y (transient (vec (repeat (+ (count ns) (count ms)) 0)))] (if-let [[i s] (first nums)] (recur (next nums) (assoc! y i (+ (y i) s))) (persistent! y)))) - James -- 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