On 17 July 2010 18:41, David Cabana <drcab...@gmail.com> wrote:
> I tried to run Jame's code, but the compiler (1.2 beta) squawked at me:
> Unable to resolve symbol: indexed in this context
>  [Thrown class java.lang.Exception]
>
> What do I need to pull in to pick up the "indexed" function?

Sorry, I should have mentioned you need Clojure 1.2.0 beta,
Clojure-Contrib 1.2.0 beta, and you need to include "indexed" from the
clojure.contrib.seq namespace:

 (use '[clojure.contrib.seq :only (indexed)])

For version 1.1.0, it needs a little adjusting. The following code
should work under 1.1.0 (but I haven't tested this):

 (use '[clojure.contrib.seq-utils :only (indexed)])

 (defn convolve [ns ms]
   (loop [nums (for [[i n] (indexed ns)
                    [j m] (indexed ms)] [(+ i j) (+ n m)])
         y    (vec (repeat (+ (count ns) (count ms)) 0))]
    (if-let [[i s] (first nums)]
      (recur (next nums) (assoc y i (+ (y i) s)))
      y)))

This code will be slower, however, as it isn't using transients.
Transients are a way of speeding up manipulating data structures by
assuming you don't need to keep around the old copies.

- 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

Reply via email to