Re: Noob evaluation question
- To: mathgroup at smc.vnet.net
- Subject: [mg74168] Re: Noob evaluation question
- From: Bill Rowe <readnewsciv at sbcglobal.net>
- Date: Tue, 13 Mar 2007 03:41:03 -0500 (EST)
On 3/12/07 at 10:08 PM, heycarnut at gmail.com (heycarnut) wrote: >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.) If you are going to use Position in this manner, the way to do what you want is as follows: m=Random[Integer, {1, 9}]; Position[{1, 2, 3, 4, 5, 6, 7, 8, 9}, _?(# <= m&)] But this is rather inefficient More efficient would be Range[Random[Integer, {1,9}]] Or if you need a n X 1 array List/@Range[Random[Integer, {1,9}]] -- To reply via email subtract one hundred and four