Last active
          December 30, 2015 09:29 
        
      - 
      
- 
        Save rigibun/7809658 to your computer and use it in GitHub Desktop. 
    SKIコンビネータのような何か
  
        
  
    
      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
    
  
  
    
  | def S(x): | |
| return lambda y: lambda z: x(z)(y(z)); | |
| def K(x): | |
| return lambda y: x; | |
| def I(x): | |
| return S(K)(K)(x); | |
| def succ(x): | |
| return S(S(K(S))(K))(x) | |
| def dec(x): | |
| return x(lambda x: x+1)(0) | |
| def __numh(x, y): | |
| if(x == 0): | |
| return y | |
| else: | |
| return __numh(x-1, succ(y)) | |
| def num(x): | |
| return __numh(x, K(I)) | |
| def main(): | |
| def loop(x, y): | |
| if dec(x) < dec(y): | |
| print(dec(x)) | |
| loop(succ(x), y) | |
| loop(num(0), num(10)) | |
| if __name__ == '__main__' : | |
| main() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment