Sam Hu wrote:
Sorry for my stepping in,but as a beginner in D ,I think maybe you( all of you
experts) have interest to hear what he think after he read the book:This is
really really great!Thank you so much for your great job!
Thanks, Sam. I saved your comments and will modify the book accordingly.
To get you going:
Here a couple of questions regarding first chapter:
1.foreach (line; stdin.byLine) {
Did not mention how to read data from file *hamlet.txt* to the analyse.If I
want to run the test case,I don't know how.
You'd need to input it in the command line with "<", e.g. progname <
hamlet.txt.
2. foreach (word; splitter(strip(line))) {
2.1 what's the purpose of splitter(strip(line)) ,I can guess a bit but not
sure;
2.2 In the first place you used split,after that you use splitter;
split() splits a string by whitespace in one operation. splitter() does
the same, but lazily - one at a time, as you go through the foreach
loop. The advantage of the latter is that it does not require temporary
storage.
3.string[] words = array(freqs.keys);
what's array? I can not find it from phobos,was I missing something?If
yes,please forgive me.
It's in std.array (added fairly recently).
4.sort!((a, b) { return freqs[a] > freqs[b]; })(words);
cann't get compiled under dmd 2.031.
Walter!!!
This has worked on and off like forever. One day I'll break into
Walter's house and etch that code onto his LCD monitor.
5.abstract class IncrementalStat : Stat {...}
Why need this extra abstract class which derived from interface Stat?For class Max,Min and AVG,does't it work fine just implementing the Stat?For a beginner,it confused me a lot.I think it would be much better to explain more here.
Will do.
At the very begining,I am typing while reading to test all the impressive
examples,but very quicky I found I am lost starting at the point of my
qestion#1-4.So finally I gave up to test the example,just read.This is my
experience.
Thank you again and best regards,
Sam
Thanks, Sam.
Andrei