Length of an SLIst ?

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Apr 2 14:07:04 PDT 2012


On 4/2/12, Justin Whear <justin at economicmodeling.com> wrote:
> Classic singly-linked lists must be iterated to determine length, so use
> std.range.walkLength on it.

Specifically call it on its range. You can get a range by slicing the
slist, e.g.:

import std.range;
import std.container;

void main()
{
    auto s = SList!int(1, 2, 5, 10);
    assert(walkLength(s[]) == 4);
}


More information about the Digitalmars-d-learn mailing list