Skip to main content
1 of 2
Gabriel
  • 1.9k
  • 12
  • 24

Intermediate logs with large calculations

I've came upon a few methods of how to display "processing" information while Mathematica is running. But, from what I've understood, this only works in between lines of codes. Is it possible to display a "how far is something being processed"-information during a line of code?

For example, I wish to Map a function g over a very large list, for example:

Map[ g , Sort[Apply[Join, Table[Range[1000000], {1000}]]] ],

which will take quite some time. Now, because the list consists of 1000 times every number between 1 and 1000000, could it be possible do display (as a temporary display), which number is being processed?

I have thought of using Print and changing the function being mapped to

Map[ (Print[#]; g[#]) &, Sort[Apply[Join, Table[Range[1000000], {1000}]]] ],

but I was wondering if there was any "faster" method, which wouldn't print out every number of the list, but for example every 1000th number. I have thought about If before Print, but I think this method would take too much extra time.

Any thoughts? Thanks in advance!

Gabriel
  • 1.9k
  • 12
  • 24