startsWith

fnuint startsWith(alias pred = (a, b) => a == b, Range, Needles...)(Range doesThisStart, Needles withOneOfThese) if (isInputRange!Range && Needles.length > 1 && allSatisfy!(canTestStartsWith!(pred, Range), Needles))

Checks whether the given

input range starts with (one

of) the given needle(s) or, if no needles are given, if its front element fulfils predicate pred.

For more information about pred see find.

Parameters

predPredicate to use in comparing the elements of the haystack and the needle(s). Mandatory if no needles are given.
doesThisStartThe input range to check.
withOneOfTheseThe needles against which the range is to be checked, which may be individual elements or input ranges of elements.
withThisThe single needle to check, which may be either a single element or an input range of elements.

Returns

0 if the needle(s) do not occur at the beginning of the given range;

otherwise the position of the matching needle, that is, 1 if the range starts with withOneOfThese[0], 2 if it starts with withOneOfThese[1], and so on.

In the case where doesThisStart starts with multiple of the ranges or elements in withOneOfThese, then the shortest one matches (if there are two which match which are of the same length (e.g. "a" and 'a'), then the left-most of them in the argument list matches).

In the case when no needle parameters are given, return true iff front of doesThisStart fulfils predicate pred.

fnbool startsWith(alias pred = "a == b", R1, R2)(R1 doesThisStart, R2 withThis) if (isInputRange!R1 && isInputRange!R2 && is(typeof(binaryFun!pred(doesThisStart.front, withThis.front)) : bool))

Ditto

fnbool startsWith(alias pred = "a == b", R, E)(R doesThisStart, E withThis) if (isInputRange!R && is(typeof(binaryFun!pred(doesThisStart.front, withThis)) : bool))

Ditto

fnbool startsWith(alias pred, R)(R doesThisStart) if (isInputRange!R && ifTestable!(typeof(doesThisStart.front), unaryFun!pred))

Ditto