Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a function doSomethingComplicated[...] that takes about 10s on average to evaluate. My list, listOfArgs has about 10000 elements. I'd like to monitor the progress of Map[doSomethingComplicated, listOfArgs] without having it ever occupying a big area of the screen. What's best way to do that?

share|improve this question

2 Answers 2

up vote 25 down vote accepted

Using MapIndexed, which also gives you the index of the element in the list instead of Map would be very convenient. That way, you can set up a Print or a PrintTemporary cell. For example:

f = (Pause[0.2]; PrintTemporary[First@#2]; #^2) &; (* your complicated function *)
MapIndexed[f, Range[10]]

(* 1
  {1, 4, 9, 16, 25, 36, 49, 64, 81, 100} *)

With a PrintTemporary cell, it prints all the output, but the cell disappears when the evaluation is complete, saving you the trouble of cleaning the mess.

You can also print directly to the messages notebook using the PrintToConsole function from my answer here. This keeps your current working notebook clean and you can always check in the other to see the progress.

Another option is to use side-effects and increment a variable, which allows you to use Monitor. For example:

g = (Pause[0.2]; i = First@#2 + 1; #^2) &;
Block[{i = 1}, Monitor[MapIndexed[g, Range[10]], i]]

See this answer by Brett Champion for the different ways in which you can create a progress bar to suit your needs.

share|improve this answer
You could write a general function to do this: MapMonitored[f_, args_List] := Module[{x = 0}, Monitor[MapIndexed[(x = #2[[1]]; f[#1]) &, args], ProgressIndicator[x/Length[args]]]] – Ian Hinder Apr 10 '14 at 7:23

With the 10.3 release and introduction of Echo there is neat simple way:

Just wrap Echo around w/e you map:

Echo[f[#]] & /@ Range[5]

enter image description here

And if you want to suppress large outputs, you can do something like

MapIndexed[(Echo["", First[#2]]; Sin[#1]) &, Range[5]]

enter image description here

which is similar to print but pretty.

share|improve this answer
This will occupy a very big/tall area of the screen, and in a way Not Pretty^TM doesn't it? – qazwsx Oct 31 at 23:28
@qazwsx i was just updating on a new function. people should use this to their convenience. – Vitaliy Kaurov Nov 1 at 9:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.