filter

fun <T> Sequence<T>.filter(predicate: (T) -> Boolean): Sequence<T>(source)

Retains matching elements in source order, testing only as far as the consumer requests. hasNext may advance the source and invoke the retained predicate. Repeated hasNext calls reuse a cached element, including null. Each traversal has its own cache.