A correction. 1+?(n-1) provides the index of the (element occupying) the second position, 2+?(n-2) for the third, etc.
Sorry for any confusion. On 11 Jan 2016 10:11 pm, "Matthew Baulch" <[email protected]> wrote: > 2^.!21 is greater than 64 and 2^.!20 is less, so I'm guessing roll is not > implemented with arbitrary precision arithmetic. > > Until that happens, you could implement your own roll verb using J > primitives that do utilise extended precision. Maybe someone has already > written one? Otherwise, you could use foreign (!:) to call a script, or a > dll to do the job. Nevertheless, I'm not sure if A. could handle such large > permutation indices either. > > Alternatively, roll can be used to shuffle in other ways. Suppose you wish > to shuffle an array with n elements. Use ?n to choose the index of the > element that will occupy the first position. Then ?(n-1) provides the index > of the second, ?(n-2) the third, and so on. Much more efficient —if less > elegant— than ?!. And it works for very large n. > On 11 Jan 2016 9:22 pm, "Eddie Bracho" <[email protected]> wrote: > >> >> (? ! 21) >> >> |domain error >> >> | ( ?!21) >> >> >> >> Is this intended behavior? I'm trying to shuffle an array by providing a >> random permutation to Anagram (A.), but this limitation does not allow me >> to shuffle arrays with more than 20 elements. >> >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
