Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE FlexibleInstances #-}
- {-# LANGUAGE IncoherentInstances #-}
- -- | Main entry point to the application.
- module Main where
- import Data.Monoid
- import Control.Monad
- type Knight = (Int,Int)
- move::Knight->[Knight]
- move (x,y) = do
- (x',y') <- [(x+1,y+2),(x+2,y+1),(x+1,y-2),(x+2,y-1),(x-1,y+2),(x-2,y+1),(x-1,y-2),(x-2,y-1)]
- guard $ (x' `elem` [1..8]) && (y' `elem` [1..8])
- return (x',y')
- instance (Monad m) => Monoid (a-> m a) where
- mempty = return
- mappend = (>=>)
- -- | The main entry point.
- main :: IO ()
- main = do
- print $ (mconcat [move | _ <- [1..1]]) (1,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement