sliceUntil

Return the prefix of haystack where pred is not satisfied.

  1. Array sliceUntil(Array haystack, Needle needle, OpenRight openRight = Yes.openRight)
  2. Array sliceUntil(Array haystack, OpenRight openRight = Yes.openRight)
    Array
    sliceUntil
    (
    alias pred = "a"
    Array
    )
    (
    Array haystack
    ,
    OpenRight openRight = Yes.openRight
    )
    if (
    isDynamicArray!Array
    )

Examples

1 import std.typecons : No;
2 
3 int[] a = [ 1, 2, 4, 7, 7, 2, 4, 7, 3, 5];
4 assert(a.sliceUntil(7) == [1, 2, 4]);
5 assert(a.sliceUntil!"a == 7" == [1, 2, 4]);
6 assert(a.sliceUntil(7, No.openRight) == [1, 2, 4, 7]);

Meta