Re: Creating Structs/Classes at runtime?

2013-02-18 Thread Brian Brady
On Tuesday, 19 February 2013 at 01:09:06 UTC, Ali Çehreli wrote: [...] How about an OO solution? That looks awesome. :) I'll have a play with it and see if I can bend it to my will. Thanks for the help. Like I said, I'm a bit of a noob, so a push in a more suitable direction is always apprec

Re: Creating Structs/Classes at runtime?

2013-02-18 Thread Brian Brady
On Monday, 18 February 2013 at 16:54:59 UTC, Ali Çehreli wrote: [...] You mean like this? 10,20,label,1,2,3,4 Then what are 10 and 20 on that line? Do they belong to the previous label? If so, I think this format is too free-form to be parsed by a general solution like csvReader. It looks li

Re: Creating Structs/Classes at runtime?

2013-02-18 Thread Brian Brady
On Monday, 18 February 2013 at 12:28:22 UTC, bearophile wrote: [...] Since some time I am maintaining most of the D code on Rosettacode. What's broken in that program? "it doesn't work" is too much vague. Bye, bearophile Apologies. My wording was poor. I believe the RosettaCode code worked

Re: Creating Structs/Classes at runtime?

2013-02-18 Thread Brian Brady
On Monday, 18 February 2013 at 05:26:39 UTC, Ali Çehreli wrote: Thank you for the working solution. [...] Looking at the sample file you provide, what you call "variables" look like data points. Yes, apologies. Different languages using different terms to describe, essentially the same thing.

Re: Creating Structs/Classes at runtime?

2013-02-17 Thread Brian Brady
On Monday, 18 February 2013 at 00:52:12 UTC, Adam D. Ruppe wrote: [...] --- auto text = "Name,Occupation,Salary\r" "Joe,Carpenter,30\nFred,Blacksmith,40\r\n"; foreach(record; csvReader!(string[string]) (text, null)) { writefln("%s works as a %s and earns $%s pe

Creating Structs/Classes at runtime?

2013-02-17 Thread Brian Brady
Hi Ok first ... is this possible? Or wise? Being mostly self taught with regards to programming I sometimes wonder if the way I'm going about something is even the right approach, never mind whether my code is logical. So if this seems ludicrous then please tell me my approach is silly and poi

Re: Calculating/Averaging over a struct value

2012-03-21 Thread Brian Brady
Thanks for the replies. Timons reply answers my question ... now I just have to figure out how :P

Calculating/Averaging over a struct value

2012-03-21 Thread Brian Brady
All This might be relatively trivial so please point me at documentation to read if it is. I am creating an array of Structs(is this the best thing to do) as per the example below. #! /usr/bin/rdmd import std.array; import std.csv; import std.stdio; import std.string; struct Data { string Dat

Re: reading in text files

2011-08-24 Thread Brian Brady
== Quote from Johannes Pfau (s...@example.com)'s article > Brian Brady wrote: > >All > > > >I am working through Andrei Alexandrescus "The D Programming Language" > >but have hit a road block fairly early on. > > > >There is a program in the

reading in text files

2011-08-24 Thread Brian Brady
All I am working through Andrei Alexandrescus "The D Programming Language" but have hit a road block fairly early on. There is a program in the book which is designed to read through a text file and do a simple word count. The program looks like this: import std.stdio, std.string; void main() {