Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created June 10, 2010 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swannodette/433269 to your computer and use it in GitHub Desktop.
Save swannodette/433269 to your computer and use it in GitHub Desktop.
(ns unchecked-remainder-test)
(defn create-test-ary []
(let [a (longs (make-array Long/TYPE 100))]
(amap a i result
(aset result i (long (rand-int 100))))))
(defn ^:static test-map [ary]
(amap ary idx result
(let [i (unchecked-remainder idx 4)
j (if (= idx (long 0)) i (unchecked-divide idx 10))]
(aset result idx (long j)))))
(defn ^:static test-reduce ^long [ary ^long i ^long j]
(let [ary (longs ary)]
(areduce ary i sum (long 0)
(+ sum (aget ary i)))))
(test-map (create-test-ary)) ; [Thrown class java.lang.NoClassDefFoundError]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment