I need to select n
elements from a list, which satisfy a condition. I need something like
Take[Select[r, (Length[FactorInteger[#]] > 100)&], 500]
but r
might be something like Range[10^10]
, and I don't want Select
to range over 10^10
elements when I need only first 500.
Cases
has a number restriction:Cases[r, x_ /; Length[FactorInteger[x]] > 100, 1, 500]
. But remember that if the length ofSelect[r, ...]
is a problem, then surely the length ofr
itself must be an even bigger problem, right? $\endgroup$Select[Range[500],#<600&,200]===Range[200]
$\mapsto$True
. Perhaps you're asking for a way to pass a lazy-evaluating list to a select type operation? $\endgroup$