Ranking poker hands: Difference between revisions
Jump to navigation
Jump to search
Miraheze>Marshall (Created page with "This article uses Dyalog APL to rank poker hands using the rules of [https://en.wikipedia.org/wiki/Texas_hold_%27em Texas hold 'em] and other popular poker variants. The f...") |
Miraheze>Marshall |
||
Line 8: | Line 8: | ||
cmp ← {⍺⍵-⍥(⊃⍋)⍵⍺} | cmp ← {⍺⍵-⍥(⊃⍋)⍵⍺} | ||
cmphand ← cmp ⍥ handrank | cmphand ← cmp ⍥ handrank | ||
</source> | |||
The <source lang=apl inline>cmphand</source> function compares two hands to yield ¯1 if the left hand is better, 1 if the right is better, and 0 if they are tied. In the talk Marshall calls it by inverting a display function (a task which Dyalog's [[Inverse]] cannot yet handle): | |||
<source lang=apl> | |||
I ← ⌷⍤0 99 | I ← ⌷⍤0 99 | ||
disp ← I¨ ∘ ((2↓⎕D),'TJQKA')('♣♢♡♠') ⍤ 1 | disp ← I¨ ∘ ((2↓⎕D),'TJQKA')('♣♢♡♠') ⍤ 1 |