Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

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