On Sat, Sep 18, 2010 at 9:22 AM, Alexander Mikhailov <[email protected]> wrote:
> we want to randomly extract a few
> items from different places in the array. We may generate 11 numbers from 0 
> to 5*6*7 (not including the last, 210th)
>
> idxs =. ?. num $ */ shp
>
> but then we'll need to make sure we don't have repetitions and add more
> numbers until all 11 are unique.
>
> We can try to (re)invent a non-repeating algorithm.

Or you can just use the builtin deal dyad:

   idxs=: num ? */ shp NB. no repetitions

Ambrus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to