Created
May 13, 2015 11:55
-
-
Save wrist/9876b11d48ded91dcb82 to your computer and use it in GitHub Desktop.
sugoi haskell chapter14 problem
This file contains 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
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