code review based on what I learned from D

2015-07-04 Thread Szabo Bogdan via Digitalmars-d-learn
Hi, Recently while I was reviewing some swift code, a colleague left me the impression that I am the one with the bad habits and these were learned while coding in D. I still think that I proposed some changes to avoid some bugs but I was told that I am focusing on defensive programming and t

Re: Switching rows with columns

2015-07-04 Thread via Digitalmars-d-learn
On Saturday, 4 July 2015 at 16:29:44 UTC, Marc Schütz wrote: Try std.range.transposed: http://dlang.org/phobos/std_range.html#.transposed Does this work with user-defined types? I defined two structs that implement the InputRange(possibly ForwardRange) interface, an integer range and a range

Re: turning an array of structs into a struct of arrays

2015-07-04 Thread Laeeth Isharc via Digitalmars-d-learn
Posted short write-up here. Please make it better... http://wiki.dlang.org/Transforming_slice_of_structs_into_struct_of_slices

Re: turning an array of structs into a struct of arrays

2015-07-04 Thread Laeeth Isharc via Digitalmars-d-learn
I can use FieldTypeTuple and FieldNameTuple, but I am a bit lost as to how without static foreach to loop through these in order to generate a mixin to declare the new type. I can turn it into a string, but what is the better option? The simplest solution is something like: template SOA(S

Re: turning an array of structs into a struct of arrays

2015-07-04 Thread Artur Skawina via Digitalmars-d-learn
On 07/03/15 12:52, Laeeth Isharc via Digitalmars-d-learn wrote: > I have an array of structs eg > > struct PriceBar > { > DateTime date; > double open; > double high; > double low; > double close; > } > > (which fields are present in this particular struct will depend on template > arg

Re: Switching rows with columns

2015-07-04 Thread via Digitalmars-d-learn
On Saturday, 4 July 2015 at 15:28:56 UTC, Tanel Tagaväli wrote: I have a range of ranges and need to change it so the elements are column-aligned instead of row-aligned. For example, [[1, 2, 3], [4, 5, 6], [7, 8, 9]] would change into [[1, 4, 7], [2, 5, 8], [3, 6, 0]]. Can I even do this w

Switching rows with columns

2015-07-04 Thread via Digitalmars-d-learn
I have a range of ranges and need to change it so the elements are column-aligned instead of row-aligned. For example, [[1, 2, 3], [4, 5, 6], [7, 8, 9]] would change into [[1, 4, 7], [2, 5, 8], [3, 6, 0]]. Can I even do this with ranges, and if so, how?

Re: Array operations, dynamic arrays and length

2015-07-04 Thread jmh530 via Digitalmars-d-learn
On Thursday, 2 July 2015 at 19:27:57 UTC, J Miller wrote: I knew that automatic allocation doesn't happen, but I'm confused by the fact if you explicitly declare "c" with "int[] c;" and then assign "c[] = a[] * b[]", versus using "auto c = a[] * b[]", you get two different errors (array length

Re: How to setup GDC with Visual D?

2015-07-04 Thread Guy Gervais via Digitalmars-d-learn
On Saturday, 4 July 2015 at 08:34:00 UTC, Johannes Pfau wrote: It's kinda fascinating that GDC/MinGW seems to work for some real world applications. I haven't really tried a "real world application" as of yet; mostly small puzzle-type problems to get a feel for D. I did run into a problem w

Re: How to setup GDC with Visual D?

2015-07-04 Thread Johannes Pfau via Digitalmars-d-learn
Am Sat, 04 Jul 2015 06:30:31 + schrieb "Marko Grdinic" : > On Friday, 3 July 2015 at 23:45:15 UTC, Guy Gervais wrote: > > On Friday, 3 July 2015 at 19:17:28 UTC, Marko Grdinic wrote: > >> Any advice regarding how I can get this to work? Thanks. > > > > I got GDC to work with VS2013 + VisualD b