haskell-karel/interface.md
Matej Focko 965e6d8f35
Add public interface
Signed-off-by: Matej Focko <me@mfocko.xyz>
2020-11-08 16:13:53 +01:00

2.7 KiB

Karel Language Reference

Primitives

  • step :: Karel -> Karel
    Moves Karel one intersection forward
  • turnLeft :: Karel -> Karel
    Pivots Karel 90 degrees left
  • pickBeeper :: Karel -> Karel
    Takes a beeper from the current intersection and puts it in the beeper bag
  • putBeeper :: Karel -> Karel
    Takes a beeper from the beeper bag and puts it at the current intersection

Sensors

  • frontIsClear :: Karel -> Bool
    Returns True if there is no wall directly in front of Karel. Returns False if there is a wall.
  • beepersPresent :: Karel -> Bool
    Returns True if Karel is standing at an intersection that has a beeper, False otherwise
  • facingNorth :: Karel -> Bool
    Returns True if Karel is facing north, False otherwise
  • beepersInBag :: Karel -> Bool
    Returns True if there is at least one beeper in Karel's beeper bag, False if the beeper bag is empty

Super Karel Language Reference

Super Karel is an extension to the basic Karel the Karel library. Super Karel is "equipped" with additional sensors.

Sensors

  • frontIsBlocked :: Karel -> Bool
    Returns True if there is a wall directly in front of Karel, False otherwise.
  • leftIsClear :: Karel -> Bool
    Returns True if there is no wall immediately to Karel's left, False if there is
  • leftIsBlocked :: Karel -> Bool
    Returns True if there is a wall immediately to Karel's left, False otherwise
  • rightIsClear :: Karel -> Bool
    Returns True if there is no wall immediately to Karel's right, False if there is
  • rightIsBlocked :: Karel -> Bool
    Returns True if there is a wall immediately to Karel's right, False otherwise
  • no_beepers_present :: Karel -> Bool
    Returns True if there is not beeper at the current intersection, False if there is a beeper at the current intersection
  • notFacingNorth :: Karel -> Bool
    Returns True if Karel is not facing north, False if he is facing north
  • facingSouth :: Karel -> Bool
    Returns True if Karel is facing south, False otherwise
  • notFacingSouth :: Karel -> Bool
    Returns True if Karel is not facing south, False if he is facing south
  • facingEast :: Karel -> Bool
    Returns True if Karel is facing east, False otherwise
  • notFacingEast :: Karel -> Bool
    Returns True if Karel is not facing east, False if he is facing east
  • facingWest :: Karel -> Bool
    Returns True if Karel is facing west, False otherwise
  • notFacingWest :: Karel -> Bool
    Returns True if Karel is not facing west, False if he is facing west
  • noBeepersInBag :: Karel -> Bool
    Returns True if Karel's beeper bag is empty, False if there is at least one beeper in the beeper bag