Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

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:

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

(* 1
   2
   ...
   ...
  {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 heremy 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:

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

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

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:

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

(* 1
   2
   ...
   ...
  {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:

Clear[g]
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.

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:

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

(* 1
   2
   ...
   ...
  {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:

Clear[g]
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.

added 219 characters in body; added 29 characters in body; added 168 characters in body
Source Link
rm -rf
  • 89.3k
  • 21
  • 297
  • 479

One option would be to useUsing 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:

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

(* 1
   2
   ...
   ...
  {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:

Clear[g]
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.

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

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

(* 1
   2
   ...
   ...
  {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.

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:

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

(* 1
   2
   ...
   ...
  {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:

Clear[g]
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.

Source Link
rm -rf
  • 89.3k
  • 21
  • 297
  • 479

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

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

(* 1
   2
   ...
   ...
  {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.