The filter operator applies a predicate to each emitted element and only allows them through if they pass:
Let's say that we have a sequence of integers and we want to only work with prime integers, that is, the integer should be greater than one and only divisible by itself and 1.
Let's add a helper extension to our Helper file in the playground. This will be an extension on the Int type to determine whether an integer is a prime number:
// Extension on Int to check if a number is prime or not public extension Int { func isPrime() -> Bool { guard self > 1 else { return false } var isPrimeFlag = true for index in 2