- ; handeval.hex
- ; a language script for hexdroid
- ; Builds a rank histogram from a hand and names a simple category.
- alias rankcount {
- ; $1- = space-separated ranks, e.g. "A A K A 9"
- set %hand $list($1-) ; a real list
- set %hist $map() ; rank -> count
- foreach %r %hand {
- set %n $calc($get(%hist,%r) + 1)
- setat %hist %r %n
- }
- ; find the top count
- set %top 0
- foreach %k $keys(%hist) {
- if ($get(%hist,%k) > %top) { set %top $get(%hist,%k) }
- }
- if (%top == 4) { echo $chan four of a kind }
- elseif (%top == 3) { echo $chan three of a kind }
- elseif (%top == 2) { echo $chan a pair }
- else { echo $chan high card }
- }