Created
          July 1, 2016 21:22 
        
      - 
      
- 
        Save joshwcomeau/2b446ec1c45cc72032f3762456b728fc to your computer and use it in GitHub Desktop. 
    Snail
  
        
  
    
      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
    
  
  
    
  | const reverse = array => [...array].reverse(); | |
| const compose = (a, b) => x => a(b(x)); | |
| const flipMatrix = matrix => ( | |
| matrix[0].map((column, index) => ( | |
| matrix.map(row => row[index]) | |
| )) | |
| ); | |
| const rotateMatrix = compose(flipMatrix, reverse); | |
| const flipMatrixCounterClockwise = compose(reverse, rotateMatrix); | |
| const rotateMatrixCounterClockwise = compose(reverse, flipMatrix); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment