Matej Focko
170a64ef77
- Use internal modules for helper functions - Clean up API - Add `facing` to Karel and `notFacing` to SuperKarel - Rename functions for creating world and Karel Signed-off-by: Matej Focko <me@mfocko.xyz>
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 = not . facingNorth
|
|
|
|
facingSouth :: Karel -> Bool
|
|
facingSouth = facing South
|
|
|
|
notFacingSouth :: Karel -> Bool
|
|
notFacingSouth = not . facingSouth
|
|
|
|
facingEast :: Karel -> Bool
|
|
facingEast = facing East
|
|
|
|
notFacingEast :: Karel -> Bool
|
|
notFacingEast = not . facingEast
|
|
|
|
facingWest :: Karel -> Bool
|
|
facingWest = facing West
|
|
|
|
notFacingWest :: Karel -> Bool
|
|
notFacingWest = not . facingWest
|
|
|
|
noBeepersInBag :: Karel -> Bool
|
|
noBeepersInBag = not . beepersInBag
|