Re: Problem using a loop to generate data for Point function

*To*: mathgroup at smc.vnet.net*Subject*: [mg35616] Re: [mg35602] Problem using a loop to generate data for Point function*From*: "Johannes Ludsteck" <johannes.ludsteck at wiwi.uni-regensburg.de>*Date*: Tue, 23 Jul 2002 01:51:14 -0400 (EDT)*Organization*: Universitaet Regensburg*Sender*: owner-wri-mathgroup at wolfram.com

Dear Michael, your most important problem is the strategy to use loops in Mathematica. My advice: don't. Unfortunately you didn't append your code consisting of four nested loops. Surely the problem can be solved without loops and becomes clearer and more readable then. Here are three solutions for you problem: Show[Graphics[Table[Point[{i,i}],{i,10}]]] ListPlot[Table[{i,i},{i,10}]] ListPlot[Range[10]] So please try to avoid loops in Mathematica. Loops produce long confusing code and slow down evaluation time. Best regards, Johannes Ludsteck On 22 Jul 2002, at 2:11, Michael Carnright wrote: > For[i = 1, i < 10, i++, Show[Graphics[Point[{i, i}]]]] > > This genereates nine graphics with one point each. I was trying to > generate one graphic with nine points. I see my problem as calling > the Point function nine times instead of only once. I wish to use the > data generated by the loop on a single graphic. > > Thanks in advance for help on this :) > > P.S. In the end I will be doing three For loops in a nested formation > to generate the data to put on one graphic. > > -Michael > <><><><><><><><><><><><><><><><><><> Johannes Ludsteck Institut fuer Volkswirtschaftslehre Lehrstuhl Prof. Dr. Moeller Universitaet Regensburg Universitaetsstrasse 31 93053 Regensburg Tel +49/0941/943-2741