Skip to content

Instantly share code, notes, and snippets.

@wrist
Created May 13, 2015 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wrist/9876b11d48ded91dcb82 to your computer and use it in GitHub Desktop.
Save wrist/9876b11d48ded91dcb82 to your computer and use it in GitHub Desktop.
sugoi haskell chapter14 problem
import Control.Monad()
type Birds = Int
type Pole = (Birds, Birds)
landLeft :: Birds -> Pole -> Either String Pole
landLeft n (left, right)
| abs ((left + n) - right) < 4 = Right (left + n, right)
| otherwise = Left ("Last state: " ++ show (left + n, right))
landRight :: Birds -> Pole -> Either String Pole
landRight n (left, right)
| abs (left - (right + n)) < 4 = Right (left, right + n)
| otherwise = Left ("Last state: " ++ show (left, right + n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment