On Wednesday, 11 December 2019 at 20:08:37 UTC, Meta wrote:
import std.algorithm;
import std.range;
void mapAccepter(E)(InputRange!E r)
{
import std.array: array;
import std.stdio: writeln;
auto collected = r.array;
writeln(collected);
}
void main()
{
int[] nums = [1, 2, 3];
auto evenness = inputRangeObject(map!(n => n % 2 ==
0)(nums));
mapAccepter(evenness);
}
I guess I should mention, that if you are expecting a range of
booleans, you can of course write mapAccepter as a non-templated
function:
void mapAccepter(InputRange!bool r);
But if you want to support any type of input range, the function
needs to at least be templated on the element type of the range.