haskell-karel/SuperKarel.hs
Matej Focko e8972e94e5
Implement first version
Signed-off-by: Matej Focko <me@mfocko.xyz>
2020-11-08 16:14:08 +01:00

45 lines
1,007 B
Haskell

module SuperKarel where
import Karel
frontIsBlocked :: Karel -> Bool
frontIsBlocked = not . frontIsClear
leftIsClear :: Karel -> Bool
leftIsClear = frontIsClear . turnLeft
leftIsBlocked :: Karel -> Bool
leftIsBlocked = not . leftIsClear
rightIsClear :: Karel -> Bool
rightIsClear = frontIsClear . turnLeft . turnLeft . turnLeft
rightIsBlocked :: Karel -> Bool
rightIsBlocked = not . rightIsClear
noBeepersPresent :: Karel -> Bool
noBeepersPresent = not . beepersPresent
notFacingNorth :: Karel -> Bool
notFacingNorth = not . facingNorth
facingSouth :: Karel -> Bool
facingSouth = (== South) . direction
notFacingSouth :: Karel -> Bool
notFacingSouth = not . facingSouth
facingEast :: Karel -> Bool
facingEast = (== East) . direction
notFacingEast :: Karel -> Bool
notFacingEast = not . facingEast
facingWest :: Karel -> Bool
facingWest = (== West) . direction
notFacingWest :: Karel -> Bool
notFacingWest = not . facingWest
noBeepersInBag :: Karel -> Bool
noBeepersInBag = not . beepersInBag