48 lines
1 KiB
Haskell
48 lines
1 KiB
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
|
|
|
|
notFacing :: Direction -> Karel -> Bool
|
|
notFacing dir = not . facing dir
|
|
|
|
notFacingNorth :: Karel -> Bool
|
|
notFacingNorth = notFacing North
|
|
|
|
facingSouth :: Karel -> Bool
|
|
facingSouth = facing South
|
|
|
|
notFacingSouth :: Karel -> Bool
|
|
notFacingSouth = notFacing South
|
|
|
|
facingEast :: Karel -> Bool
|
|
facingEast = facing East
|
|
|
|
notFacingEast :: Karel -> Bool
|
|
notFacingEast = notFacing East
|
|
|
|
facingWest :: Karel -> Bool
|
|
facingWest = facing West
|
|
|
|
notFacingWest :: Karel -> Bool
|
|
notFacingWest = notFacing West
|
|
|
|
noBeepersInBag :: Karel -> Bool
|
|
noBeepersInBag = not . beepersInBag
|