Re: Stop iteration iconstructing Table
- To: mathgroup at smc.vnet.net
- Subject: [mg90574] Re: Stop iteration iconstructing Table
- From: dh <dh at metrohm.ch>
- Date: Mon, 14 Jul 2008 05:21:12 -0400 (EDT)
- References: <g59tn8$omh$1@smc.vnet.net>
Hi Angel,
if you stop a Table command, it does not return the result. You may do
this using a breakable loop (Do,While,For) and Append. However, if you
use an ordinary list to append to, this is very inefficient, as the
whole list is reallocated each time. Therefore, the it is much faster to
create a nested list, that does not need reallocation. E.g. to create a
list from 1..5 with a loop that runs to 10
list={};
Do[
AppendTo[list,{i}];
If[i>=5,Break[]];
,{i,10}];
list= Flatten[list]
hope this helps, Daniel
malawk at gmail.com wrote:
> Hi
>
> Sorry I'm not very familiar with Mathematica. I want to create a
> simple Table of this sort:
>
> Table[{{$1, $2, $3, ...}, {...}, ..., {...}}, {i,1,imax}],
>
> where $2 decreases as the iteration proceeds, and imax should be such
> that only those elements with $2 >= 100 are returned. When $2 goes
> below 100 then the iteration should stop and the final Table given. I
> want to do this because I'm not interested in computing those elements
> whose $2 <100.
>
> Any ideas how can I do this simple thing?
>
> Thank you so much!
> Angel
>
>
>
--
Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:dh at metrohm.com>
Internet:<http://www.metrohm.com>