Skip to content

Instantly share code, notes, and snippets.

@iseebi
Created March 11, 2015 12:01
Show Gist options
  • Save iseebi/b0b0250b4e5f29d4bde2 to your computer and use it in GitHub Desktop.
Save iseebi/b0b0250b4e5f29d4bde2 to your computer and use it in GitHub Desktop.
すごいHaskell読書会 in 大阪 2周目 #16
type Pos = (Int, Int)
checkCol :: Pos -> [Pos] -> Bool
checkCol (row, col) l = not . elem True $ map (\(_, col') -> col' == col) l
putFu :: Pos -> [Pos] -> Maybe [Pos]
putFu (row, col) l
| row < 1 = Nothing
| row > 8 = Nothing
| col < 1 = Nothing
| col > 9 = Nothing
| checkCol (row, col) l == False = Nothing
| otherwise = Just $ (row, col):l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment