> (defn countnl-lite
>  [#^bytes buf]
>  (areduce buf idx count (int 0)
>           (if (= (clojure.lang.RT/aget buf idx) 10)
>             (unchecked-add count 1)
>             count)))
>
> Key points are initializing count to a primitive integer and directly
> calling clojure's aget to avoid an unnecessary integer cast.

Are you using clojure 1.2?  If I try to set count to be (int 0) rather
than 0, I get this error:

Exception in thread "main" java.lang.RuntimeException:
java.lang.IllegalArgumentException: recur arg for primitive local:
count must be matching primitive

Even if I replace "inc" with the unchecked-add, or "cast" the result
of the inc to be "int" (replace (inc count) with (int (inc count)) )
it gives me that error.  Sort of strange...

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

Reply via email to