Re: Appending to multidimensional dynamic array

2015-05-30 Thread kerdemdemir via Digitalmars-d-learn
In your case its pretty simple. The buffer is being reused. So same memory being added multiple times to the candidate. Just slap on a .dup when adding it. candidate ~= line; Thanks a lot replacing the line above with candidate ~= [line[0].dup, line[1].dup]; My problem is solved .

Re: Mixin - to get to the content-type `MapResult!(__lambda1, int[]).MapResult`

2015-05-30 Thread Dennis Ritchie via Digitalmars-d-learn
On Sunday, 31 May 2015 at 06:04:40 UTC, Dennis Ritchie wrote: mixin(newStr[0 .. $ - 4] ~ `[idx,` ~ newStr[$ - 4 .. $]); mixin(newStr[0 .. $ - 4] ~ `idx,` ~ newStr[$ - 4 .. $]);

Re: Mixin - to get to the content-type `MapResult!(__lambda1, int[]).MapResult`

2015-05-30 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 30 May 2015 at 23:58:44 UTC, Ali Çehreli wrote: On 05/30/2015 12:19 PM, Dennis Ritchie wrote: First, unfortunately, I don't understand you completely. Sorry about that... :) Nothing to worry about! Now you will understand me till the end... :) Regarding that, the intermediate

attribute alias? eg: asm @my_alias {...} alias my_alias=pure nothrow @trusted @nogc;

2015-05-30 Thread Timothee Cour via Digitalmars-d-learn
Is there a way to alias attributes? alias my_alias=pure nothrow @trusted @nogc; asm @my_alias {...} This came up here: https://github.com/Hackerpilot/libdparse/issues/50 Or at least to do the following in a less ugly way? static if(__VERSION__<2067) enum asm_att=``; else enum asm_att=`pure noth

Re: Mixin - to get to the content-type `MapResult!(__lambda1, int[]).MapResult`

2015-05-30 Thread Ali Çehreli via Digitalmars-d-learn
On 05/30/2015 12:19 PM, Dennis Ritchie wrote: First, unfortunately, I don't understand you completely. Sorry about that... :) Second, you can do almost anything with string mixins: Write a function that returns the code as string and just mix it in. :) Debug with pragma(msg): string makeCo

Re: Mixin - to get to the content-type `MapResult!(__lambda1, int[]).MapResult`

2015-05-30 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 30 May 2015 at 19:19:21 UTC, Dennis Ritchie wrote: I want to access the intermediate generation `range.front`. Is it possible? :) In other words, I want to expand the array to the application to him of 'writeln'!

Re: Mixin - to get to the content-type `MapResult!(__lambda1, int[]).MapResult`

2015-05-30 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 30 May 2015 at 06:50:09 UTC, Ali Çehreli wrote: On 05/29/2015 06:07 PM, Dennis Ritchie wrote: > Hi, > This code prints the arrays: > [5] > [6] > [7] > > import std.stdio, std.algorithm; > > static int idx; Do you want to share that for the first element of every two-element array

Re: data-oriented struct abstraction ?

2015-05-30 Thread short2cave via Digitalmars-d-learn
On Saturday, 30 May 2015 at 14:23:37 UTC, Marc Schütz wrote: Something like this? struct S { static int[] a_; static float[] b_; const size_t idx; @property ref int a() { return a_[idx]; } @property ref float b() { return b_[idx]; } void opAssign(c

Re: Appending to multidimensional dynamic array

2015-05-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 30 May 2015 at 12:41:42 UTC, kerdemdemir wrote: By the way I am posting the same question to stackoverflow at the same time. Does sending questions to stackoverflow as well as here not desirable for D community? If so I will just write here. I like it there, SO is a bit easier to

Re: data-oriented struct abstraction ?

2015-05-30 Thread short2cave via Digitalmars-d-learn
On Saturday, 30 May 2015 at 14:32:01 UTC, Anonymous wrote: This may be somewhat related. http://forum.dlang.org/thread/ckeqxhkqjyvmqodrf...@forum.dlang.org#post-m9rj0d:242m9e:243:40digitalmars.com https://github.com/economicmodeling/soa On Saturday, 30 May 2015 at 14:17:51 UTC, short2cave wro

Re: data-oriented struct abstraction ?

2015-05-30 Thread Anonymous via Digitalmars-d-learn
This may be somewhat related. http://forum.dlang.org/thread/ckeqxhkqjyvmqodrf...@forum.dlang.org#post-m9rj0d:242m9e:243:40digitalmars.com https://github.com/economicmodeling/soa On Saturday, 30 May 2015 at 14:17:51 UTC, short2cave wrote: On Saturday, 30 May 2015 at 13:57:28 UTC, Rikki Cattermo

Re: data-oriented struct abstraction ?

2015-05-30 Thread via Digitalmars-d-learn
On Saturday, 30 May 2015 at 14:17:51 UTC, short2cave wrote: template, man, think template. Once it's done it can be instantiated at the ∞ with any struct used as model. A library template, a type cons. Once the template done, it has 0 cost. Right. But I also think to get a good API, you need t

Re: data-oriented struct abstraction ?

2015-05-30 Thread via Digitalmars-d-learn
Something like this? struct S { static int[] a_; static float[] b_; const size_t idx; @property ref int a() { return a_[idx]; } @property ref float b() { return b_[idx]; } void opAssign(const S other) { a_[idx] = a_[other.idx];

Re: data-oriented struct abstraction ?

2015-05-30 Thread short2cave via Digitalmars-d-learn
On Saturday, 30 May 2015 at 13:57:28 UTC, Rikki Cattermole wrote: On 31/05/2015 1:49 a.m., short2cave wrote: On Saturday, 30 May 2015 at 12:34:21 UTC, Rikki Cattermole wrote: On 30/05/2015 11:46 p.m., short2cave wrote: Consider this struct: --- Foo { uint a,b,c; float d,e,f; } --- in a

Re: data-oriented struct abstraction ?

2015-05-30 Thread Rikki Cattermole via Digitalmars-d-learn
On 31/05/2015 1:49 a.m., short2cave wrote: On Saturday, 30 May 2015 at 12:34:21 UTC, Rikki Cattermole wrote: On 30/05/2015 11:46 p.m., short2cave wrote: Consider this struct: --- Foo { uint a,b,c; float d,e,f; } --- in a collection: --- Foo[] foos; --- Looping a particular member is

Re: data-oriented struct abstraction ?

2015-05-30 Thread short2cave via Digitalmars-d-learn
On Saturday, 30 May 2015 at 12:34:21 UTC, Rikki Cattermole wrote: On 30/05/2015 11:46 p.m., short2cave wrote: Consider this struct: --- Foo { uint a,b,c; float d,e,f; } --- in a collection: --- Foo[] foos; --- Looping a particular member is not cache friendly --- foreach(foo;foos){/

Re: Appending to multidimensional dynamic array

2015-05-30 Thread Rikki Cattermole via Digitalmars-d-learn
On 31/05/2015 12:41 a.m., kerdemdemir wrote: I want to append a 2D array to my 3D array. I expect it should be same as int[] arr; arr ~= 3; void readInput() { char[][][] candidate; char[] buff; size_t counter = 0; while ( stdin.readln(buff) ) { char[][] line =

Appending to multidimensional dynamic array

2015-05-30 Thread kerdemdemir via Digitalmars-d-learn
I want to append a 2D array to my 3D array. I expect it should be same as int[] arr; arr ~= 3; void readInput() { char[][][] candidate; char[] buff; size_t counter = 0; while ( stdin.readln(buff) ) { char[][] line = buff.chomp().split(); writeln(line);

Re: data-oriented struct abstraction ?

2015-05-30 Thread Rikki Cattermole via Digitalmars-d-learn
On 30/05/2015 11:46 p.m., short2cave wrote: Consider this struct: --- Foo { uint a,b,c; float d,e,f; } --- in a collection: --- Foo[] foos; --- Looping a particular member is not cache friendly --- foreach(foo;foos){/*foo.a = ...*/} --- but to write clear, understable, structured

data-oriented struct abstraction ?

2015-05-30 Thread short2cave via Digitalmars-d-learn
Consider this struct: --- Foo { uint a,b,c; float d,e,f; } --- in a collection: --- Foo[] foos; --- Looping a particular member is not cache friendly --- foreach(foo;foos){/*foo.a = ...*/} --- but to write clear, understable, structured code, the struct is necessary. So, is it pos

Re: Reset Range

2015-05-30 Thread Philpax via Digitalmars-d-learn
On Saturday, 30 May 2015 at 08:36:02 UTC, tcak wrote: I have never interested in "Range" topic till now, but with Walter's presentation, I took a look at it today. Ali has a nice lesson page about it (http://ddili.org/ders/d.en/ranges.html). What I don't get is the mechanism to reset a range

Reset Range

2015-05-30 Thread tcak via Digitalmars-d-learn
I have never interested in "Range" topic till now, but with Walter's presentation, I took a look at it today. Ali has a nice lesson page about it (http://ddili.org/ders/d.en/ranges.html). What I don't get is the mechanism to reset a range. I mean, you use a range with foreach, but then it is