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))
>>>
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
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]
>>> (
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
]
>>(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
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:
>>
>>
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
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