digitalmars.D.announce - reddit.com: first Chapter of TDPL available for free
- Andrei Alexandrescu (3/3) Aug 03 2009 http://www.reddit.com/r/programming/comments/975ng/diving_into_the_d_pro...
- Moritz Warning (4/9) Aug 03 2009 Your secret will be safe. ;-)
- Nick Sabalausky (7/10) Aug 03 2009 I just read the first section and already I'm impressed with it. Great j...
- Robert Fraser (2/5) Aug 03 2009 Or a pun ;-P.
- Jarrett Billingsley (2/8) Aug 03 2009 The mailing list lag is killing me.
- Jarrett Billingsley (2/14) Aug 03 2009 That's no typo; that's a pun!
- Walter Bright (2/3) Aug 03 2009 That's no moon!
- Andrei Alexandrescu (3/19) Aug 03 2009 It's a pun...
- MIURA Masahiro (3/4) Aug 03 2009 Thanks for sharing it!
- Andrei Alexandrescu (3/9) Aug 03 2009 Noted, thanks.
- Pablo Ripolles (9/15) Aug 04 2009 And, of course, the same goes for cmperinch's.
- Andrei Alexandrescu (3/26) Aug 04 2009 Thanks, Pablo.
- Jos van Uden (42/48) Aug 08 2009 Is this supposed to compile? I keep getting error messages.
- Jarrett Billingsley (11/60) Aug 08 2009 t
- Jos van Uden (3/75) Aug 08 2009 Yep, that solves it, in both cases.
http://www.reddit.com/r/programming/comments/975ng/diving_into_the_d_programming_language_tdpl/ (Don't tell anyone, but I plan to rewrite it.) Andrei
Aug 03 2009
On Mon, 03 Aug 2009 17:01:34 -0500, Andrei Alexandrescu wrote:http://www.reddit.com/r/programming/comments/975ng/diving_into_the_d_programming_language_tdpl/(Don't tell anyone, but I plan to rewrite it.) AndreiYour secret will be safe. ;-) Thanks for sharing.
Aug 03 2009
"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message news:h57mno$26gm$2 digitalmars.com...http://www.reddit.com/r/programming/comments/975ng/diving_into_the_d_programming_language_tdpl/ (Don't tell anyone, but I plan to rewrite it.) AndreiI just read the first section and already I'm impressed with it. Great job :) One little niggle though: At the end of the paragraph that explains the hello world's import statement, it says "Repeated imports of the same file are of no import." Sounds like a typo snuck in there.
Aug 03 2009
Nick Sabalausky wrote:One little niggle though: At the end of the paragraph that explains the hello world's import statement, it says "Repeated imports of the same file are of no import." Sounds like a typo snuck in there.Or a pun ;-P.
Aug 03 2009
On Mon, Aug 3, 2009 at 7:40 PM, Robert Fraser<fraserofthenight gmail.com> wrote:Nick Sabalausky wrote:The mailing list lag is killing me.One little niggle though: At the end of the paragraph that explains the hello world's import statement, it says "Repeated imports of the same file are of no import." Sounds like a typo snuck in there.Or a pun ;-P.
Aug 03 2009
On Mon, Aug 3, 2009 at 7:34 PM, Nick Sabalausky<a a.a> wrote:"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message news:h57mno$26gm$2 digitalmars.com...That's no typo; that's a pun!http://www.reddit.com/r/programming/comments/975ng/diving_into_the_d_programming_language_tdpl/ (Don't tell anyone, but I plan to rewrite it.) AndreiI just read the first section and already I'm impressed with it. Great job :) One little niggle though: At the end of the paragraph that explains the hello world's import statement, it says "Repeated imports of the same file are of no import." Sounds like a typo snuck in there.
Aug 03 2009
Jarrett Billingsley wrote:That's no typo;That's no moon!
Aug 03 2009
Nick Sabalausky wrote:"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message news:h57mno$26gm$2 digitalmars.com...It's a pun... Andreihttp://www.reddit.com/r/programming/comments/975ng/diving_into_the_d_programming_language_tdpl/ (Don't tell anyone, but I plan to rewrite it.) AndreiI just read the first section and already I'm impressed with it. Great job :) One little niggle though: At the end of the paragraph that explains the hello world's import statement, it says "Repeated imports of the same file are of no import." Sounds like a typo snuck in there.
Aug 03 2009
Andrei Alexandrescu wrote:http://www.reddit.com/r/programming/comments/975ng/diving_into_the_d_progra ming_language_tdpl/Thanks for sharing it! Typos: in section 1.1, there are inchPerFoot's and inchperfoot's.
Aug 03 2009
MIURA Masahiro wrote:Andrei Alexandrescu wrote:Noted, thanks. Andreihttp://www.reddit.com/r/programming/comments/975ng/diving_into_the_d_progra ming_language_tdpl/Thanks for sharing it! Typos: in section 1.1, there are inchPerFoot's and inchperfoot's.
Aug 03 2009
MIURA Masahiro Wrote:Andrei Alexandrescu wrote:And, of course, the same goes for cmperinch's. Some other observations are the following: In section 1.2 you refer to prior "if" statements introduced in above samples, what samples? is there maybe a 0 chapte?r In section 1.4, subsection "Building a Vocabulary" it's not very clear what stdio.byLine is... I mean, it says nothing about how to feed the text to the program. Also in subsection "Counting Frequencies. Lambda Functions" there appears a call to "splitter" function, isn't it named "split" instead? Besides the hamlet.txt URL doesn't work already, maybe a bit of indirection here would also be appreciated... In section 1.5, maybe I miss the reason of importing "std.range". In section 1.6, "stats" is a variable and stats.d is the name of the file/module, shouldn't stats.d be renamed to stat.d so that "stat.Max" makes sense and so the name of the program becomes stat and it's invoked that way in the command line? Or maybe rename "stat.Max" to "stats.Max"? Besides, aren't you talking firstly about Min? Why not to illustrate the thing with "stat.Min" instead of "stat.Max"? In the references to different other chapters the word sometimes appears capitalized and sometimes doesn't. Cheers!http://www.reddit.com/r/programming/comments/975ng/diving_into_the_d_progra ming_language_tdpl/Thanks for sharing it! Typos: in section 1.1, there are inchPerFoot's and inchperfoot's.
Aug 04 2009
Pablo Ripolles wrote:MIURA Masahiro Wrote:Thanks, Pablo. AndreiAndrei Alexandrescu wrote:And, of course, the same goes for cmperinch's. Some other observations are the following: In section 1.2 you refer to prior "if" statements introduced in above samples, what samples? is there maybe a 0 chapte?r In section 1.4, subsection "Building a Vocabulary" it's not very clear what stdio.byLine is... I mean, it says nothing about how to feed the text to the program. Also in subsection "Counting Frequencies. Lambda Functions" there appears a call to "splitter" function, isn't it named "split" instead? Besides the hamlet.txt URL doesn't work already, maybe a bit of indirection here would also be appreciated... In section 1.5, maybe I miss the reason of importing "std.range". In section 1.6, "stats" is a variable and stats.d is the name of the file/module, shouldn't stats.d be renamed to stat.d so that "stat.Max" makes sense and so the name of the program becomes stat and it's invoked that way in the command line? Or maybe rename "stat.Max" to "stats.Max"? Besides, aren't you talking firstly about Min? Why not to illustrate the thing with "stat.Min" instead of "stat.Max"? In the references to different other chapters the word sometimes appears capitalized and sometimes doesn't. Cheers!http://www.reddit.com/r/programming/comments/975ng/diving_into_the_d_progra ming_language_tdpl/Thanks for sharing it! Typos: in section 1.1, there are inchPerFoot's and inchperfoot's.
Aug 04 2009
Andrei Alexandrescu wrote:http://www.reddit.com/r/programming/comments/975ng/diving_into_the_d_progra ming_language_tdpl/ (Don't tell anyone, but I plan to rewrite it.) AndreiIs this supposed to compile? I keep getting error messages. import std.stdio, std.string; void main() { uint[string] dic; foreach (line; stdin.byLine) { // Break sentence into words string[] words = split(strip(line)); // Add each word in the sentence to the vocabulary foreach (word; words) { if (word in dic) continue; // nothing to do uint newID = dic.length; dic[word] = newID; writeln(newID, '\t', word); } } } test.d(7): Error: function std.string.split (immutable(char)[] s) does not match parameter types (char[]) test.d(7): Error: cannot implicitly convert expression (strip(line)) of type char[] to immutable(char)[] test.d(7): Error: expected 2 function arguments, not 1 I've changed the code to: import std.stdio; import std.string; void main() { uint[string] dic; foreach (line; stdin.byLine) { string[] words = split(strip!(string)(line)); foreach (word; words) { if (word in dic) { continue; } uint newID = dic.length; dic[word] = newID; writeln(newID, '\t', word); } } } but I still get an error... test.d(12): Error: cannot implicitly convert expression (line) of type char[] to immutable(char)[]
Aug 08 2009
On Sat, Aug 8, 2009 at 8:44 PM, Jos van Uden<jvu nospam.nl> wrote:Andrei Alexandrescu wrote:gramming_language_tdpl/http://www.reddit.com/r/programming/comments/975ng/diving_into_the_d_pro=t(Don't tell anyone, but I plan to rewrite it.) AndreiIs this supposed to compile? I keep getting error messages. import std.stdio, std.string; void main() { =A0 uint[string] dic; =A0 foreach (line; stdin.byLine) { =A0 =A0 =A0// Break sentence into words =A0 =A0 =A0string[] words =3D split(strip(line)); =A0 =A0 =A0// Add each word in the sentence to the vocabulary =A0 =A0 =A0foreach (word; words) { =A0 =A0 =A0 =A0 if (word in dic) continue; // nothing to do =A0 =A0 =A0 =A0 uint newID =3D dic.length; =A0 =A0 =A0 =A0 dic[word] =3D newID; =A0 =A0 =A0 =A0 writeln(newID, '\t', word); =A0 =A0 =A0} =A0 } } test.d(7): Error: function std.string.split (immutable(char)[] s) does no=match parameter types (char[]) test.d(7): Error: cannot implicitly convert expression (strip(line)) of t=ypechar[] to immutable(char)[] test.d(7): Error: expected 2 function arguments, not 1 I've changed the code to: import std.stdio; import std.string; void main() { =A0 =A0uint[string] dic; =A0 =A0foreach (line; stdin.byLine) { =A0 =A0 =A0 =A0string[] words =3D split(strip!(string)(line)); =A0 =A0 =A0 =A0foreach (word; words) { =A0 =A0 =A0 =A0 =A0 =A0if (word in dic) { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0continue; =A0 =A0 =A0 =A0 =A0 =A0} =A0 =A0 =A0 =A0 =A0 =A0uint newID =3D dic.length; =A0 =A0 =A0 =A0 =A0 =A0dic[word] =3D newID; =A0 =A0 =A0 =A0 =A0 =A0writeln(newID, '\t', word); =A0 =A0 =A0 =A0} =A0 =A0} } but I still get an error... test.d(12): Error: cannot implicitly convert expression (line) of type char[] to immutable(char)[]It's not documented, but the .byLine method returns char[], not immutable(char)[] (string). This is because the 'line' variable is reused on each new line of the input, to improve speed. I think to solved this, you should use: auto words =3D split(strip(line.idup)); The .idup creates a new duplicate of the line that is immutable. Now, why split() doesn't take a const(char)[] is beyond me..
Aug 08 2009
Jarrett Billingsley wrote:On Sat, Aug 8, 2009 at 8:44 PM, Jos van Uden<jvu nospam.nl> wrote:Yep, that solves it, in both cases. JosAndrei Alexandrescu wrote:It's not documented, but the .byLine method returns char[], not immutable(char)[] (string). This is because the 'line' variable is reused on each new line of the input, to improve speed. I think to solved this, you should use: auto words = split(strip(line.idup)); The .idup creates a new duplicate of the line that is immutable. Now, why split() doesn't take a const(char)[] is beyond me..http://www.reddit.com/r/programming/comments/975ng/diving_into_the_d_programming_language_tdpl/ (Don't tell anyone, but I plan to rewrite it.) AndreiIs this supposed to compile? I keep getting error messages. import std.stdio, std.string; void main() { uint[string] dic; foreach (line; stdin.byLine) { // Break sentence into words string[] words = split(strip(line)); // Add each word in the sentence to the vocabulary foreach (word; words) { if (word in dic) continue; // nothing to do uint newID = dic.length; dic[word] = newID; writeln(newID, '\t', word); } } } test.d(7): Error: function std.string.split (immutable(char)[] s) does not match parameter types (char[]) test.d(7): Error: cannot implicitly convert expression (strip(line)) of type char[] to immutable(char)[] test.d(7): Error: expected 2 function arguments, not 1 I've changed the code to: import std.stdio; import std.string; void main() { uint[string] dic; foreach (line; stdin.byLine) { string[] words = split(strip!(string)(line)); foreach (word; words) { if (word in dic) { continue; } uint newID = dic.length; dic[word] = newID; writeln(newID, '\t', word); } } } but I still get an error... test.d(12): Error: cannot implicitly convert expression (line) of type char[] to immutable(char)[]
Aug 08 2009