SList.each

Eagerly iterate over each element in the list and call fun over each element. This should be used to iterate through const and immutable lists.

Normally, the entire list 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).

template each(alias fun)
Flag!"each"
each
(
this Q
)
()
if (
is(typeof(unaryFun!fun(T.init)))
)

Members

Functions

each
Flag!"each" each()
Undocumented in source. Be warned that the author may not have intended to support it.

Imports

Flag (from std.typecons)
public import std.typecons : Flag, Yes, No;
Undocumented in source.
No (from std.typecons)
public import std.typecons : Flag, Yes, No;
Undocumented in source.
Yes (from std.typecons)
public import std.typecons : Flag, Yes, No;
Undocumented in source.
unaryFun (from std.functional)
public import std.functional : unaryFun;
Undocumented in source.

Parameters

fun

unary function to apply on each element of the list.

Return Value

Yes.each if it has iterated through all the elements in the list, or No.each otherwise.

Complexity: O(n).

Examples

import std.typecons : Flag, Yes, No;

auto isl = immutable SList!int([1, 2, 3]);

static bool foo(int x) { return x > 0; }

assert(isl.each!foo == Yes.each);

Meta