Re: Working with arrays (flatten, transpose, verfify rectangular)

2022-07-22 Thread anonymouse via Digitalmars-d-learn
On Friday, 22 July 2022 at 05:17:49 UTC, anonymouse wrote: On Wednesday, 20 July 2022 at 09:18:29 UTC, anonymouse wrote: As for task 3, while I understand the concept of transposing a matrix, I'm not sure how to even begin. By not knowing how to begin, I mean that I don't know how to

Re: Working with arrays (flatten, transpose, verfify rectangular)

2022-07-21 Thread anonymouse via Digitalmars-d-learn
On Wednesday, 20 July 2022 at 09:18:29 UTC, anonymouse wrote: As for task 3, while I understand the concept of transposing a matrix, I'm not sure how to even begin. By not knowing how to begin, I mean that I don't know how to generalize the algorithm so that it applies to an array of

Re: Working with arrays (flatten, transpose, verfify rectangular)

2022-07-21 Thread anonymouse via Digitalmars-d-learn
On Wednesday, 20 July 2022 at 16:15:33 UTC, Salih Dincer wrote: On Wednesday, 20 July 2022 at 09:18:29 UTC, anonymouse wrote: Given an array of arbitrary dimensions, I would like to accomplish three things: 1) verify that it is rectangular (e.g. all elements have the same length,

Re: Working with arrays (flatten, transpose, verfify rectangular)

2022-07-21 Thread anonymouse via Digitalmars-d-learn
On Wednesday, 20 July 2022 at 20:47:28 UTC, ag0aep6g wrote: (Aside: You don't need that many backticks to mark code fragments.) Thought I was following the instructions but it looks like I got a bit carried away. lol. You've got a bug there. This should pass, but fails with your version:

Re: Working with arrays (flatten, transpose, verfify rectangular)

2022-07-20 Thread ag0aep6g via Digitalmars-d-learn
On 20.07.22 11:18, anonymouse wrote:     d     auto isRectangular(A)(A a) if (isArray!A)     {     bool result;     size_t length = a[0].length;     foreach (e; a) {     result = e.length == length;     }     return

Re: Working with arrays (flatten, transpose, verfify rectangular)

2022-07-20 Thread Salih Dincer via Digitalmars-d-learn
On Wednesday, 20 July 2022 at 09:18:29 UTC, anonymouse wrote: Given an array of arbitrary dimensions, I would like to accomplish three things: 1) verify that it is rectangular (e.g. all elements have the same length, all sub-elements have the same length, etc.) 2) flatten

Working with arrays (flatten, transpose, verfify rectangular)

2022-07-20 Thread anonymouse via Digitalmars-d-learn
Given an array of arbitrary dimensions, I would like to accomplish three things: 1) verify that it is rectangular (e.g. all elements have the same length, all sub-elements have the same length, etc.) 2) flatten and return the flattened copy 3) transpose and return