Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 5
    $\begingroup$ Try Sow and Reap and see how those compare. And do not forget to include all the time spent agonizing over how to make this as fast as absolutely possible and time spent asking for help and waiting for answers and time spent trying to incorporate suggestions into your before and after calculations of how long all this REALLY took to complete. $\endgroup$ Commented Oct 16, 2024 at 4:35
  • 1
    $\begingroup$ That is exactly what Sow/Reap were invented for. To collect data in a loop. Also, better not use For in Mathematica. You can Do instead. There is no need to use For ever in Mathematica. I think it was mistake to even have it in the language in first place. But too late now to remove it. $\endgroup$ Commented Oct 16, 2024 at 10:11
  • $\begingroup$ Me, I’m a fan of For loops. But I agree, Reap/Sow are the tools for the task at hand. $\endgroup$ Commented Oct 16, 2024 at 15:50
  • $\begingroup$ For those who come to this page (my question) unfamiliar with Reap and Sow, as I was, I recommend starting your discovery with mathematica.stackexchange.com/a/181603 . And, of course, searching for the SE-Mathematica tag [sow-reap] $\endgroup$ Commented Oct 16, 2024 at 23:48
  • 1
    $\begingroup$ I was only meaning that whereas some people deplore use of For loops, I'm rather fond of them. Using Reap/Sow is sort of orthogonal to what loop type one might use. $\endgroup$ Commented Oct 17, 2024 at 1:41