On Sat, Jun 4, 2011 at 6:32 AM, bOR_ <boris.sch...@gmail.com> wrote:

> (defn plusS ^shorts [^shorts array ^shorts arr2]
>
>
>   "adds two Short arrays"
>
>
>   (amap array idx ret (short (+ (aget array idx) (aget arr2 idx)))))
>
>
>
>
>
> (defn plusI ^ints [^ints array ^ints arr2]
>
>
>   "adds two Int arrays."
>
>
>   (amap array idx ret (+ (aget array idx) (aget arr2 idx))))
>

The correct way to write plusS:

(defn ^shorts plusS [^shorts array ^shorts arr2]
  (amap array idx ret (short (+ (long (aget array idx)) (long (aget arr2
idx))))))

fns can only return long, double, Object so you need to move the hint to the
fn var. Primitive arithmetic is only supported for long/double so you need
to cast to long.

David

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