Description Usage Arguments Value Author(s) Examples
Takes each integer between 1 and 52 and turns it into a card. Used in deal1() and tourn1().
1 | switch2(x)
|
x |
a vector of integers between 1 and 52. |
num |
numbers (2-14) of the cards |
st |
suits (1-4) of the cards |
Frederic Paik Schoenberg
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function(x){
## takes a number 1-52, and turns it into a card:
## returns a list, where the 1st is the number (2-14), and 2nd is suit (1-4).
n = length(x)
y = list(num=x, st=rep(1,n))
for(i in c(1:n)){
a = 1
while(a>0){
if(y$num[i]<14) a = -1 else{y$st[i] = y$st[i]+1
y$num[i] = y$num[i]-13
}
}
}
y$num = y$num+1
y
} ## end of switch2
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.