MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: in a loop

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111879] Re: in a loop
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Mon, 16 Aug 2010 05:56:32 -0400 (EDT)

Table with TableForm still seems easier when you want to add column or 
row headers. With Grid, etc., you have to explicitly adjoin rows or 
columns with the headers.

On 8/15/2010 7:39 AM, Helen Read wrote:
> On 8/14/2010 6:34 AM, Bill Rowe wrote:
>>
>> For loops return Null. So, unless you specifically arrange for
>> an output by using Print or something equivalent, no output is
>> ever returned by a For loop.
>>
>> That is
>>
>> For[i = 0, i<   5, i++; i]
>>
>> will return nothing for exactly the same reason.
>>
>> One other observation, the listing created by
>>
>> dirnames = Names["$*Directory*"];
>> For[i = 0, i<   Length[dirnames],i++; Print[dirnames[[i]]]]
>>
>> is more created by
>>
>> ColumnForm[Names["$*Directory*"]]
>>
>> or
>>
>> TableForm[Names["$*Directory*"]]
>>
>> which seems to me a simpler more direct approach than using
>> Print in a For loop. These methods are also more efficient as
>> there is no need to compute the number of items and increment an
>> indexing variable.
>
> Even simpler:
>
> Column[Names["$*Directory*"]]
>
> Ever since Grid and Column were introduced, I find no need for TableForm
> anymore.
>
>

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: How can I change $GeoLocation
  • Next by Date: Re: DSolve difficulties ...
  • Previous by thread: Re: in a loop
  • Next by thread: Re: in a loop