【发布时间】:2021-05-20 09:50:38
【问题描述】:
我有一个 float32arrays 数组,并且想要一个函数将它们展平成一个大的 float 32array
const first = new Float32Array([1,2]);
const second = new Float32Array([3,4,5]);
const third = new Float32Array([6,7,8,9]);
const chunks = [first,second,third];
//this function should take an array of flaot32arrays
//and return a new float32array which is the combination of the float32arrays in the input.
const flattenFloat32 = (chunks) => {
//Need code for this function
return
}
console.log(flattenFloat32(chunks))
【问题讨论】:
-
创建一个新数组,其大小是其他数组大小的总和,然后复制值。
-
这个答案适合你吗? stackoverflow.com/questions/14071463/…
-
@Watanabe.N - 很好的发现。
标签: javascript flatten