MathGroup Archive 2003

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

Search the Archive

Re: Pick random element from list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43320] Re: [mg43276] Pick random element from list
  • From: Dr Bob <drbob at bigfoot.com>
  • Date: Sun, 24 Aug 2003 04:55:23 -0400 (EDT)
  • References: <200308231209.IAA25172@smc.vnet.net>
  • Reply-to: drbob at bigfoot.com
  • Sender: owner-wri-mathgroup at wolfram.com

pickRandom = Part[#, Random[ Integer, {1, Length@#}]] &

Bobby

On Sat, 23 Aug 2003 08:09:02 -0400 (EDT), Khufu <a7tv-pbcm at spamex.com> 
wrote:

> Hi Mathgroup,
>
> Is there a built-in function to pick a random element from a list?
>
> I'm looking for something simple, like:
>
> list = {1,2,3,a,b,c}
> PickRandom[list] returns "b", etc.
>
> If this isn't built-in, can anyone suggest a simple/efficient
> implementation?
>
> Many thanks,
> -K
>
>



-- 
majort at cox-internet.com
Bobby R. Treat


  • Prev by Date: Re: Are points co-planar in (numDimensions-1)?
  • Next by Date: Re: Those Pesky Minus Signs
  • Previous by thread: Pick random element from list
  • Next by thread: Re: Pick random element from list