MathGroup Archive 2005

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

Search the Archive

Re: reducing the time of constructing a List


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