Hello, Im a 3rd year Comp Sci student in Edmonton Alberta, Canada.

Ive learned how to use C, and dabbled in C++ in school. Im also in a Oop course using Java.

I picked up the book The D Programming Language by Alexrei Alexandrescu a few years ago. Lately Im really wanting to get into D, as It seems like a better version of C, and feels like java in a way.



However;

Ive run into a bit of a problem while writing some code. Im not sure if Im doing something wrong, or maybe the things Im using are depreciated??

Code Blocks does not give any messages as to what is going wrong. I haven't configured anything, and am not familiar with messing around with IDE settings.

Its directly based off of the example on page 8.

here is the code that does not compile:


import std.stdio, std.string;

void main() { ... }

void dict() {

    uint[string] dictionary;

    foreach(line; stdin.byLine()) {

//chunk = splitter(strip(line); ## errors because of splitter

foreach(word; splitter(strip(line))) { ## errors because of splitter ??

        if(word in dictionary) continue;

        //writeln(dictionary.length);  ## gives 0 ??

        auto newID = dictionary.length;
        dictionary[word] = newId;


        writeln(newID, ' ', word);

        }
    }

}




Im not sure what Im doing wrong here.

modifying the code to just print the result of splitLines results in the entire line.
and just having splitter give a sting to print also errors.

Please help, thanks!

Reply via email to