Last active
          December 13, 2015 22:19 
        
      - 
      
- 
        Save egisatoshi/4983387 to your computer and use it in GitHub Desktop. 
    Mah-jong in next Egison
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | ; | |
| ; Mah-jong example | |
| ; | |
| (define $shuntsu : (PatternConstructor [Hai (Collection Hai)] (Collection Hai)) | |
| (pattern-constructor [$pat1 $pat2] | |
| <cons (& <num $s $n> pat1) | |
| <cons <num ,s ,(+ n 1)> | |
| <cons <num ,s ,(+ n 2)> | |
| pat2>>>)) | |
| (define $kohtsu : (PatternConstructor [Hai (Collection Hai)] (Collection Hai)) | |
| (pattern-constructor [$pat1 $pat2] | |
| <cons (& $pat pat1) | |
| <cons ,pat | |
| <cons ,pat | |
| pat2>>>)) | |
| (define $twin : (PatternConstructor [Hai (Collection Hai)] (Collection Hai)) | |
| (pattern-constructor [$pat1 $pat2] | |
| <cons (& $pat pat1) | |
| <cons ,pat | |
| pat2>>)) | |
| (define $agari? : (\ (Collection Hai) Bool) | |
| (function (multiset hai) | |
| {[(twin $th_1 (| (shuntsu $sh_1 (shuntsu $sh_2 (shuntsu $sh_3 (shuntsu $sh_4 <nil>)))) | |
| (shuntsu $sh_1 (shuntsu $sh_2 (shuntsu $sh_3 (kohtsu $kh_1 <nil>)))) | |
| (shuntsu $sh_1 (shuntsu $sh_2 (kohtsu $kh_1 (kohtsu $kh_2 <nil>)))) | |
| (shuntsu $sh_1 (kohtsu $kh_1 (kohtsu $kh_2 (kohtsu $kh_3 <nil>)))) | |
| (kohtsu $kh_1 (kohtsu $kh_2 (kohtsu $kh_3 (kohtsu $kh_4 <nil>)))) | |
| (twin $th_2 (twin $th_3 (twin $th_4 (twin $th_5 (twin $th_6 (twin $th_7 <nil>)))))) | |
| )) | |
| #t] | |
| [_ | |
| #f]})) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment