On 8/26/21 7:17 PM, Merlin Diavova wrote:
What I meant about the handling an empty filter is, what if I want to take an alternative route if the filter returns empty?
Then the operations downstream will not produce any results. For example, the array will be empty below:
import std.stdio; import std.range; import std.algorithm; import std.string; import std.functional; void main() { auto significantLines = stdin .byLineCopy .map!strip .filter!(not!empty) .filter!(line => line.front != '#') .array; if (significantLines.empty) { writeln("There were no significant lines."); } else { writefln!"The lines: %-(\n%s%)"(significantLines); } } Ali