diff options
author | Rich Hickey <richhickey@gmail.com> | 2007-10-28 21:43:54 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2007-10-28 21:43:54 +0000 |
commit | 9201d6427403d8e716f5cb5b999e95c1c8af9012 (patch) | |
tree | e489460c5b20c3298bfd0bebfa04631ce366e934 /src | |
parent | 63eb1b3181e42b7dd827a485a7a7dd10f308574f (diff) |
added java primitive wrapper conversion functions int long etc
Diffstat (limited to 'src')
-rw-r--r-- | src/boot.clj | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/boot.clj b/src/boot.clj index 3b29b51f..21d0eaf6 100644 --- a/src/boot.clj +++ b/src/boot.clj @@ -625,6 +625,29 @@ (import '(java.util.concurrent Executors LinkedBlockingQueue)) +(defn int [#^Number x] + (. x (intValue))) + +(defn long [#^Number x] + (. x (longValue))) + +(defn float [#^Number x] + (. x (floatValue))) + +(defn double [#^Number x] + (. x (doubleValue))) + +(defn short [#^Number x] + (. x (shortValue))) + +(defn byte [#^Number x] + (. x (byteValue))) + +(defn boolean [x] + (if x + (. Boolean TRUE) + (. Boolean FALSE))) + (defn pmap ([f coll] (let [nthreads (.. Runtime (getRuntime) (availableProcessors)) @@ -646,7 +669,8 @@ (. exec (submit task))) (replicate nthreads produce))) consume (fn [] - (if (sync nil (and (or @todo (pos? @out)) (commute out dec))) + (if (sync nil (and (or @todo (pos? @out)) + (commute out dec))) (fnseq (. q (take)) thisfn) (do (. exec (shutdown)) @@ -658,7 +682,8 @@ ((fn [collseq] (when (every seq collseq) (let [encl-fn thisfn] - (lazy-cons (map first collseq) (encl-fn (map rest collseq)))))) + (lazy-cons (map first collseq) + (encl-fn (map rest collseq)))))) (cons coll colls))))) (def *exports* @@ -693,5 +718,6 @@ doto memfn read *in* time + int long float double short byte boolean )) |