diff --git a/arrays.scad b/arrays.scad index 8c8d91c..648cc4a 100644 --- a/arrays.scad +++ b/arrays.scad @@ -496,8 +496,7 @@ function array_dim(v, depth=undef) = // transpose([3,4,5]); // Returns: [[3],[4],[5]] function transpose(arr) = arr==[]? [] : - is_list(arr[0])? [for (i=[0:len(arr[0])-1]) [for (j=[0:len(arr)-1]) arr[j][i]]] : - [for (x=arr) [x]]; + is_list(arr[0])? [for (i=[0:len(arr[0])-1]) [for (j=[0:len(arr)-1]) arr[j][i]]] : arr; diff --git a/tests/test_arrays.scad b/tests/test_arrays.scad index f305651..8b7e2c5 100644 --- a/tests/test_arrays.scad +++ b/tests/test_arrays.scad @@ -215,7 +215,7 @@ test_array_dim(); module test_transpose() { assert(transpose([[1,2,3],[4,5,6],[7,8,9]]) == [[1,4,7],[2,5,8],[3,6,9]]); assert(transpose([[1,2,3],[4,5,6]]) == [[1,4],[2,5],[3,6]]); - assert(transpose([3,4,5]) == [[3],[4],[5]]); + assert(transpose([3,4,5]) == [3,4,5]); } test_transpose();