Doing exercise from book, but I'm getting error with splitter
Andrew Brown via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jun 16 09:52:25 PDT 2014
I'm giving up
On Monday, 16 June 2014 at 16:49:46 UTC, Andrew Brown wrote:
> Sorry, comments split over two lines, this should work:
>
> import std.stdio, std.array, std.string; //need to import
> std.array
>
> void main() {
> ulong[string] dictionary; // the length property is ulong,
> not
> uint
> foreach (line; stdin.byLine()) {
> foreach (word; splitter(strip(line))) {
> if (word in dictionary) continue;
> auto newID = dictionary.length; //dictionarys need
> immutable keys, you // can create this with .idup
> dictionary[word.idup] = newID;
> writeln(newID, '\t', word);
> }
> }
> }
More information about the Digitalmars-d-learn
mailing list