Re: concat primitive arrays

2013-07-21 Thread Alex Fowler
t;>>>> the other versions faster, or make them handle any array type? >>>>> >>>>> (defn bconcat [& arrays] >>>>> (let [sizes (map count arrays) >>>>>sizes_r (vec (reductions + sizes)) >>>

Re: concat primitive arrays

2013-07-21 Thread Brian Craft
t;>> https://groups.google.com/forum/?hl=en#!topic/clojure/BayfuaqMzvs which >>>>> brings in C-like structs in. >>>>> >>>>> On Sunday, July 21, 2013 2:39:38 AM UTC+4, Brian Craft wrote: >>>>>> >>>>>> Here are

Re: concat primitive arrays

2013-07-21 Thread Brian Craft
offsets (cons 0 (drop-last sizes_r)) >>>total (last sizes_r) >>>out (float-array total)] >>>(dorun (map #(System/arraycopy %2 0 out %1 %3) offsets arrays sizes)) >>>out)) >>> >>> (defn cconcat [& arrays] >>> (

Re: concat primitive arrays

2013-07-21 Thread Brian Craft
t;>>> (defn bconcat [& arrays] >>>> (let [sizes (map count arrays) >>>>sizes_r (vec (reductions + sizes)) >>>>offsets (cons 0 (drop-last sizes_r)) >>>>total (last sizes_r) >>>>out (float-arr

Re: concat primitive arrays

2013-07-21 Thread Brian Craft
] >>(dorun (map #(System/arraycopy %2 0 out %1 %3) offsets arrays sizes)) >>out)) >> >> (defn cconcat [& arrays] >> (let [vs (map vec arrays) >>cc (apply concat vs)] >>(float-array cc))) >> >> (defn dconcat [& array

Re: concat primitive arrays

2013-07-21 Thread Alex Fowler
ys] > (let [vs (map vec arrays) >cc (reduce into [] vs)] >(float-array cc))) > > (defn econcat [& arrays] > (let [cc (reduce into [] arrays)] > (float-array cc))) > > > On Saturday, July 20, 2013 2:24:14 PM UTC-7, Brian Craft wrote: >> >>

Re: concat primitive arrays

2013-07-20 Thread Brian Craft
cc))) (defn dconcat [& arrays] (let [vs (map vec arrays) cc (reduce into [] vs)] (float-array cc))) (defn econcat [& arrays] (let [cc (reduce into [] arrays)] (float-array cc))) On Saturday, July 20, 2013 2:24:14 PM UTC-7, Brian Craft wrote: > > Is there an easy, fast way

concat primitive arrays

2013-07-20 Thread Brian Craft
Is there an easy, fast way to concat primitive arrays? I was hoping java arrays had some common interface for this, but I haven't found much of use. I mostly see code like this: byte[] c = new byte[a.length + b.length]; System.arraycopy(a, 0, c, 0, a.length); System.arraycopy(b, 0, c, a.l