Raul Miller wrote:
On 3/24/07, June Kim <[EMAIL PROTECTED]> wrote:
What is the model of Deal in terms of Roll?
This should do:
swap=: (|[EMAIL PROTECTED] { ])`[`]}
dealall=: i. ([: > [: swap&.>/ ,&.> , [: < [) [EMAIL PROTECTED]
deal=: [ {. [EMAIL PROTECTED]
The result of alpha?omega for each of the corresponding cells of alpha and omega
is a list of length alpha in which all the elments are distinct.
In particular '' as left argument and a scalar right argument should return i.0
'' ? 8
2 4 ? 8
1 3 0 0
0 7 3 6
APL evaluates alpha?omega using repeated calls to a short cut version of
mechanism for monad ?. In principle, the method is to generate random integers,
keeping those that fall within the range specified by alpha and discarding those
that do not. However, the result of dyad ? is not necessarily what you would
get by using monad ? and discarding out-of-range items from the result.
From An Implementation of J,
tick=: [ <[EMAIL PROTECTED] (* 3 : 'qrl=: (<:2^31)|(7^5)*qrl')@]
step=: <@~.@((+ (2^31)&tick)/\)@[ C. ]
arg =: <@[EMAIL PROTECTED]@] ,~ [EMAIL PROTECTED]@[ ([ ,&.> -~) ]
deal=: ([ {. >@(step&.>/)@arg)"0
(before testing it need to initialise qrl (random link) to 7^5 or other values)
See SHARP APL Reference Manual, p.178 (Berry[1979]).
--
regards,
bill
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm