Re: Noob evaluation question
- To: mathgroup at smc.vnet.net
- Subject: [mg74169] Re: [mg74144] Noob evaluation question
- From: bsyehuda at gmail.com
- Date: Tue, 13 Mar 2007 03:41:36 -0500 (EST)
basically you need to evaluate the random integer once, before the
evaluation of the Position[] function
With[{r=Random[Integer,{1,9}]},Position[Range[9],_?(#<=r&)]]
yehuda
On 3/13/07, heycarnut <heycarnut at gmail.com> wrote:
>
> Hi -
>
> Helping a buddy out with a small application, and I'm drawing a blank
> on the following.
>
> Given :
>
> Position[{1, 2, 3, 4, 5, 6, 7, 8, 9}, _?(# <= Random[Integer, {1,
> 9}] &)]
>
> How can we make the generated random number 'fixed' for the evaluation
> of Position, instead of a new number getting generated at each element
> of the list (the above is a simplified and contrived example.)
>
> Thanks
> Rob
>
>
>