Dlang: how to get the length of a SList or DList

D language developers decided that those structures are so simple that they should not maintain any kind of state. As a consequence you need to relay on external functions for finding out their length:

import std.container;
import std.range;
import std.stdio;

void main(string[] args) {
    auto data = SList!double();
    data.insert(1);
    data.insert(2);
    writeln(walkLength(data[]));
}
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply