If you are trying to pick a single random entry out of a list, you want something like: Code:
That is, randInt should be used to pick the index into the list, because it cannot pick an element out of a list directly.
If you want more than one random entry out of a list (with or without replacement), you can generate multiple indices using randInt (with replacement) or randIntNoRep (without replacement) & then use a loop to do the indexing to collect the elements into a new list.
If what you want is a random number between the lowest & highest elements in a list (regardless of whether that exact number appears in the list), you want something like: Code:
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum