The exception is because (into-array [0 1 -7 2 -1 -3 4 5 -10])
is not an array of longs, use long-array instead.

In the areduce, we also have to return ret after each computation, like so:

(defn aremove [pred ^longs ns]
  (areduce ns i ret (long-array (alength ns))
           (let [v (aget ns i)]
             (when-not (pred v)
               (aset ret i v))
             ret)))

(seq (aremove pos? (long-array [0 1 -7 2 -1 -3 4 5 -10])))
;=> (0 0 -7 0 -1 -3 0 0 -10)

The next problem is all the zeroes. I don't know how to solve this problem
with arrays. :)

Jonathan

On Fri, Nov 23, 2012 at 9:43 PM, Jim - FooBar(); <jimpil1...@gmail.com>wrote:

>   (defn aremove [pred ^longs ns]
>    (areduce ns i ret (long-array (alength ns))
>      (when-not (pred (aget ns i))
>        (aset ret i (aget ns i) ))))
>

-- 
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