unary function to apply on each element of the array.
Yes.each if it has iterated through all the elements in the array, or No.each otherwise.
Complexity: O(n).
import std.typecons : Flag, Yes, No; auto ia = immutable Array!int([1, 2, 3]); static bool foo(int x) { return x > 0; } static Flag!"each" bar(int x) { return x > 1 ? Yes.each : No.each; } assert(ia.each!foo == Yes.each); assert(ia.each!bar == No.each);
Eagerly iterate over each element in the array and call fun over each element. This should be used to iterate through const and immutable arrays.
Normally, the entire array is iterated. If partial iteration (early stopping) is desired, fun needs to return a value of type std.typecons.Flag!"each" (Yes.each to continue iteration, or No.each to stop).