Mimicing Python list of list

2015-10-26 Thread Dandyvica via Digitalmars-d-learn
Hi all, I'm trying to find out a solution to implement a generic tree or array container whose nodes can either be elements or a subtree (or sub-array). Pretty much like you can do in Python: l = [1, 2, [1, 2, 3], 4] l is a list of (integers or list of integers). Any idea on how to do that?

Re: Mimicing Python list of list

2015-10-26 Thread Meta via Digitalmars-d-learn
On Monday, 26 October 2015 at 18:46:45 UTC, Dandyvica wrote: Hi all, I'm trying to find out a solution to implement a generic tree or array container whose nodes can either be elements or a subtree (or sub-array). Pretty much like you can do in Python: l = [1, 2, [1, 2, 3], 4] l is a list o

Re: Mimicing Python list of list

2015-10-26 Thread Dandyvica via Digitalmars-d-learn
On Monday, 26 October 2015 at 19:26:08 UTC, Meta wrote: On Monday, 26 October 2015 at 18:46:45 UTC, Dandyvica wrote: Hi all, I'm trying to find out a solution to implement a generic tree or array container whose nodes can either be elements or a subtree (or sub-array). Pretty much like you c

Re: Mimicing Python list of list

2015-10-26 Thread Meta via Digitalmars-d-learn
On Monday, 26 October 2015 at 20:53:18 UTC, Dandyvica wrote: Thanks Meta, great idea. But does I'd like to have something like dynamic arrays and be able to do this: class A(T) { T _v; this(T v) { _v = v; } } auto myContainer = MyContainerArray!(A!int)(); myContainer ~= new A!int(1); myCon