Hex example

Text Detected Guest 24 Views Size: 681 bytes Posted on: Jun 17, 26 @ 3:56 AM
  1. ; handeval.hex
  2. ; a language script for hexdroid
  3. ; Builds a rank histogram from a hand and names a simple category.
  4.  
  5. alias rankcount {
  6.   ; $1- = space-separated ranks, e.g. "A A K A 9"
  7.   set %hand $list($1-)        ; a real list
  8.   set %hist $map()            ; rank -> count
  9.   foreach %r %hand {
  10.     set %n $calc($get(%hist,%r) + 1)
  11.     setat %hist %r %n
  12.   }
  13.   ; find the top count
  14.   set %top 0
  15.   foreach %k $keys(%hist) {
  16.     if ($get(%hist,%k) > %top) { set %top $get(%hist,%k) }
  17.   }
  18.   if (%top == 4) { echo $chan four of a kind }
  19.   elseif (%top == 3) { echo $chan three of a kind }
  20.   elseif (%top == 2) { echo $chan a pair }
  21.   else { echo $chan high card }
  22. }

Raw Paste

Comments 0
Login to post a comment.
  • No comments yet. Be the first.
Login to post a comment. Login or Register
We use cookies. To comply with GDPR in the EU and the UK we have to show you these.

We use cookies and similar technologies to keep this website functional (including spam protection via Google reCAPTCHA or Cloudflare Turnstile), and — with your consent — to measure usage and show ads. See Privacy.