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.
Answer
Or you can use something like this:
Monitor[
Table[Length@FactorInteger[2^n - 1], {n, 50, 500, 50}],
Grid[{{Text[Style["Integer Factorization :", Darker[Blue, 0.66]]],
ProgressIndicator[n, {50, 500}]},
{Text[Style["Factoring 2^n-1 with n : ", Darker[Blue, 0.66]]], n}},
Alignment -> Left, Dividers -> Center]]
Sorry for not using your computation, since it did not make sense to me, which is my fault. That's why I've chosen another, just to display my approach.
Comments
Post a Comment