Re: How to flatten N-dimensional array?

2020-05-24 Thread Ali Çehreli via Digitalmars-d-learn
On 5/24/20 2:37 AM, Pavel Shkadzko wrote: On Saturday, 23 May 2020 at 19:59:30 UTC, Ali Çehreli wrote: On 5/23/20 11:15 AM, Pavel Shkadzko wrote:> I have tried to implement a simple flatten function for multidimensional [...] Thank you, I was lacking practical examples for templates with

Re: How to flatten N-dimensional array?

2020-05-24 Thread Pavel Shkadzko via Digitalmars-d-learn
On Sunday, 24 May 2020 at 11:21:00 UTC, 9il wrote: On Saturday, 23 May 2020 at 18:15:32 UTC, Pavel Shkadzko wrote: [...] If the common nd-array isn't jugged (a parallelotop), you can use fuse function. -- /+dub.sdl: dependency "mir-algorithm" version="~>3.8.12" +/ import std.stdio:

Re: How to flatten N-dimensional array?

2020-05-24 Thread 9il via Digitalmars-d-learn
On Saturday, 23 May 2020 at 18:15:32 UTC, Pavel Shkadzko wrote: I have tried to implement a simple flatten function for multidimensional arrays with recursive templates but got stuck. Then I googled a little and stumped into complex https://rosettacode.org/wiki/Flatten_a_list#D implementation

Re: How to flatten N-dimensional array?

2020-05-24 Thread Pavel Shkadzko via Digitalmars-d-learn
On Saturday, 23 May 2020 at 19:59:30 UTC, Ali Çehreli wrote: On 5/23/20 11:15 AM, Pavel Shkadzko wrote:> I have tried to implement a simple flatten function for multidimensional [...] Thank you, I was lacking practical examples for templates with "if" constructs, ehh.

Re: How to flatten N-dimensional array?

2020-05-23 Thread Ali Çehreli via Digitalmars-d-learn
On 5/23/20 11:15 AM, Pavel Shkadzko wrote:> I have tried to implement a simple flatten function for multidimensional > I'd like to clarify a couple of questions first. > > How come Phobos doesn't have "flatten" function for arrays? We call in 'joiner'. I wrote something like this: import

How to flatten N-dimensional array?

2020-05-23 Thread Pavel Shkadzko via Digitalmars-d-learn
I have tried to implement a simple flatten function for multidimensional arrays with recursive templates but got stuck. Then I googled a little and stumped into complex https://rosettacode.org/wiki/Flatten_a_list#D implementation which requires your arrays to be either TreeList or Algebraic.