|
[Date Index]
[Thread Index]
[Author Index]
Re: in a loop
- To: mathgroup at smc.vnet.net
- Subject: [mg111859] Re: in a loop
- From: Helen Read <hpr at together.net>
- Date: Sun, 15 Aug 2010 07:39:56 -0400 (EDT)
- References: <i45rgj$g4u$1@smc.vnet.net>
- Reply-to: HPR <read at math.uvm.edu>
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.
--
Helen Read
University of Vermont
Prev by Date:
configuring the mathlink dev kit
Next by Date:
Re: Repost - help with list manipulation
Previous by thread:
configuring the mathlink dev kit
Next by thread:
Re: in a loop
|