MathGroup Archive 2006

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

Search the Archive

Re: A Reap Sow question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65227] Re: A Reap Sow question
  • From: David Bailey <dave at Remove_Thisdbailey.co.uk>
  • Date: Sun, 19 Mar 2006 03:19:04 -0500 (EST)
  • References: <dvdif7$a2p$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

János wrote:
> Hi,
> 
> First, thanks a lot to Valeri Astanoff, Daniel Lichtblau, David Park  
> and Carl Woll  for the valuable suggestions to my previous post.
> 
> Let say I have a construct like
> 
> collection=Reap[i=1; While[i<=10,Sow[i]];]
> 
> Is it possible to put a condition on Sow referring back to  
> collection ?  Something like:
> 
> collection=Reap[i=1; While[i<=10,If[Length[First[Last[collection]] ] 
>  >5,,Sow[i] ] ];]
> 
> If not, - I have not seen any indication in Help either way - , what  
> technique can be used to get a similar effect without resorting to  
> global lists or arrays?
> 
> Thanks ahead,
> 
> János
> 
> 
> ------------------------------------------------------
> I am seriously convinced that the world is ruled by complete  
> lunatics. The ones who are not crazy are either refraining from it,  
> or are unable to participate in it.  <Leo Tolstoy>
> 
Ignoring the infinite loop, and treating the reference to 'collection' 
on the RHS as pseudo-code - which I believe was intended, I can't see 
much point in this.

Either let the loop complete and then trim the collection afterwards as 
required, or, use Break or Throw/Catch to leave the loop after a certain 
count has been reached.

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: BinomialDistribution
  • Next by Date: Re: Unevaluated values of a[[i]]+b[[j]]
  • Previous by thread: Re: A Reap Sow question
  • Next by thread: Subscripted variables and function definitions