dropWhileRight method

Iterable<T> dropWhileRight(
  1. bool predicate(
    1. T t
    )
)

Remove all elements starting from the last as long as predicate returns true.

Implementation

Iterable<T> dropWhileRight(bool Function(T t) predicate) =>
    foldRight<Tuple2<bool, Iterable<T>>>(
      const Tuple2(true, []),
      (e, a) {
        if (!a.first) {
          return Tuple2(a.first, a.second.prepend(e));
        }

        final check = predicate(e);
        return check
            ? Tuple2(check, a.second)
            : Tuple2(check, a.second.prepend(e));
      },
    ).second;