MathGroup Archive 2005

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

Search the Archive

Re: reducing the time of constructing a List

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57595] Re: reducing the time of constructing a List
  • From: "Kezhao Zhang" <kezhao.zhang at gmail.com>
  • Date: Wed, 1 Jun 2005 06:04:32 -0400 (EDT)
  • References: <d7haeo$3pa$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Don't use the For loop, use either Map or pattern matching:

lst=If[#==1,1,0]&/@Table[Random[Integer, {0, 10}], {100000}];

lst=Table[Random[Integer, {0, 10}], {100000}]/._?(#!=1&):>0;

Hope this helps.

K. Zhang


  • Prev by Date: label origin on plot
  • Next by Date: computing the area inside a contour plot
  • Previous by thread: Re: Re: Re: label origin on plot
  • Next by thread: Re: reducing the time of constructing a List