Logo

Programming-Idioms

History of Idiom 117 > diff from v28 to v29

Edit summary for version 29 by BBaz:
New D implementation by user [BBaz]

Version 28

2016-04-07, 09:04:21

Version 29

2016-08-14, 20:29:55

Idiom #117 Get list size

Set n to the number of elements of list x.

Idiom #117 Get list size

Set n to the number of elements of list x.

Imports
import std.range.primitives;
Code
n = walkLength(x);
Comments bubble
walkLength is a generic solution that works for built-in arrays and containers that implement an input range interface.
Doc URL
https://dlang.org/phobos/std_range_primitives.html#.walkLength