You just use Seq.filter and then Seq.take with the number of results you are interested in:
Seq.filter and Seq.take are lazy, and then when seq is forced, it will stop filtering as soon as the result reaches the desired size.
Here is an example using an infinite sequence to check if it really stops filtering:
Seq.initInfinite id |> Seq.filter (fun x -> x % 2 = 0) |> Seq.take 10
And this is a functional style, so you solve the problem in FP languages ββusing a lazy collection, for example, in Haskell, which is a pure FP language, you do the same with lists: take 10 (filter (\x -> mod x 2 == 0) [0..]) .
source share