Dynamic array handling

Brad Anderson eco at gnuk.net
Thu Nov 14 13:40:44 PST 2013


On Thursday, 14 November 2013 at 21:38:39 UTC, seany wrote:
> In Very High level languages, such as scilab, you can write
>
> array_var = (1,2,3 ... etc)
>
> and then you can also write
>
> array_var = array_var(1:2,4:$)
>
> In this case, the third element is dropped, and the same 
> variable, array_var is set to be an array of a different 
> length, resizing of array and so on is automated.
>
> Is the same possible to be done in D?
>
> say,
>
> int [] a ; //initialize;
>
> a ~= 1;
> a ~= 2; //etc, polulate
>
> . . . say, we fill up 10 such elements
>
> Now, can you do like,
>
> a = somefunction_that_drops_the_4th_element(a); // a is reset,
>                                                 // and the 
> length
>                                                 // is 
> reorganized automatically

a = a.remove(3);


More information about the Digitalmars-d-learn mailing list