# Question:How to get a random selection from a specific subArrays of an Array?

## Question:How to get a random selection from a specific subArrays of an Array?

Maple

I have an Array A with 90 rows and 16 columns.

The first column of each row denotes the name of a card, while the other 15 colums of each row specify certain characteristics of that card.

Moreover I defined a couple of selection rules Ri, to define sublists of A, which contain only the entries of the first column of A and where the number of elements in Ri is known a priori.

E.g.
R1:=[0\$14]:
q:=1:
for i to 90 do
if A[i,2]=4 or A[i,2]=0 then
R1[q]:=A[i,1]:
q:=q+1:
end if:
end do:

or:
R2:=[0\$23]:
q:=1:
for i to 90 do
if (A[i,7]>=0.5 or A[i,7]=x) and (A[i,8]> 1 or A[i,8]=x) then
R2[q]:=A[i,1]:
q:=q+1:
end if:
end do:

Now, I wanted to write a proc called setup, which displays a random selection of ten different card names (i.e. the entry of the first column of each row). Moreover the procedure should  account for specified selection rules R1,R2... and a related parameter p1,p2... which are specified in the procedure´s arguments. The selection rule specifies for which sublists the proc should account for (this may be none) and the relating parameter says, how many cards should be chosen randomly from that sublist. So I tried the following:

Setup:=[0\$10]:

setup:=proc(Options::list,Parameter::list)
p:=1:
for i to nops(Options) do
Options[i]:=Shuffle(Options[i]):    <= the trouble may occur in this line, where I try to do: Ri:=Shuffle(Ri)
for j to Parameter[p] do
assign(Options[i,j],Setup[p]):
p:=p+1:
end do:
end do:
for k to 10 do
Setup[k];
end do;
end proc;

Needless to say it didn´t work. Furthermore I am very sure, that tackled that problem far too inefficient.
Therefore I am very thankful for any critique, comments and ideas that can bring me back on track.

﻿