Learn R Programming

holdem (version 1.2)

onepair1: See if you have a pair.

Description

Sees if you have a pair, and if so, finds the strength of your hand. Used by handeval().

Usage

onepair1(x)

Arguments

x

Value

returns 15*15*15*pair + 15*15*next + 15*next + next if you have a pair, or 0 otherwise.

Examples

Run this code
# NOT RUN {
##---- 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){
## 15*15*15*pair + 15*15*next + 15*next + next
a1 = unique(x)
a2 = length(a1)
if(a2 == length(x)) return(0)
a3 = rep(0,a2)
for(i in 1:a2) a3[i] = sum(x == a1[i])
a4 = max(a1[a3>1.5])
a5 = sort(c(x[x != a4],rep(0,3)),decreasing=T)
15*15*15*a4 + 225*a5[1] + 15*a5[2] + a5[3]
  }
# }

Run the code above in your browser using DataLab