I have a parallel processing code written in Wolfram Mathematica, similar to:

 {i, Select[Range[Power[2, k] - 1], # >= IntegerReverse[#, 2] &]}

My problem is that output of Select[Range[]] can be quite large, and Mathematica seems to generate whole list first and then starts iterating - I would like to avoid this to save memory and time. Basically what I am looking for is something similar to Python generators, that is to generate the iterator dynamically, only when it is needed.

What is some (preferably simple) way to achieve this? In other languages I would do it by making the parallelizing logic by myself, but I would like to utilize maximum of what Mathematica already provides.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.