delete method

Iterable<T> delete(
  1. T element
)

Remove the first occurrence of element from this Iterable.

Implementation

Iterable<T> delete(T element) =>
    foldLeft<Tuple2<bool, Iterable<T>>>(const Tuple2(true, []), (a, e) {
      if (!a.first) {
        return a.mapSecond((second) => second.append(e));
      }

      return e == element
          ? a.mapFirst((first) => false)
          : a.mapSecond((second) => second.append(e));
    }).second;