toNumericRange

Converts a range with arbitrary element types (usually strings) to a range of reals lazily. Ignores any elements that could not be successfully converted. Useful for creating an input range that can be used with this lib out of a File without having to read the whole file into an array first. The advantages to this over just using std.algorithm.map are that it's less typing and that it ignores non-convertible elements, such as blank lines.

If rangeIn is an inputRange, then the result of this function is an input range. Otherwise, the result is a forward range.

Note: The reason this struct doesn't have length or random access, even if this is supported by rangeIn, is because it has to be able to filter out non-convertible elements.

toNumericRange
(
R
)
if (
isInputRange!R
)

Examples

1 // Perform a T-test to see whether the mean of the data being input as text
2 // from stdin is different from zero.  This data might not even fit in memory
3 // if it were read in eagerly.
4 
5 auto myRange = toNumericRange( stdin.byLine() );
6 TestRes result = studentsTTest(myRange);
7 writeln(result);

Meta