2020-11-08 16:14:08 +01:00
|
|
|
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
|
|
|
|
|
2020-11-08 19:18:42 +01:00
|
|
|
notFacing :: Direction -> Karel -> Bool
|
|
|
|
notFacing dir = not . facing dir
|
|
|
|
|
2020-11-08 16:14:08 +01:00
|
|
|
notFacingNorth :: Karel -> Bool
|
|
|
|
notFacingNorth = not . facingNorth
|
|
|
|
|
|
|
|
facingSouth :: Karel -> Bool
|
2020-11-08 19:18:42 +01:00
|
|
|
facingSouth = facing South
|
2020-11-08 16:14:08 +01:00
|
|
|
|
|
|
|
notFacingSouth :: Karel -> Bool
|
|
|
|
notFacingSouth = not . facingSouth
|
|
|
|
|
|
|
|
facingEast :: Karel -> Bool
|
2020-11-08 19:18:42 +01:00
|
|
|
facingEast = facing East
|
2020-11-08 16:14:08 +01:00
|
|
|
|
|
|
|
notFacingEast :: Karel -> Bool
|
|
|
|
notFacingEast = not . facingEast
|
|
|
|
|
|
|
|
facingWest :: Karel -> Bool
|
2020-11-08 19:18:42 +01:00
|
|
|
facingWest = facing West
|
2020-11-08 16:14:08 +01:00
|
|
|
|
|
|
|
notFacingWest :: Karel -> Bool
|
|
|
|
notFacingWest = not . facingWest
|
|
|
|
|
|
|
|
noBeepersInBag :: Karel -> Bool
|
|
|
|
noBeepersInBag = not . beepersInBag
|