Extend documentation of added functions and tooling
- Add periods to sentences in documentation - Add new functions: `facing` and `notFacing` - Add description to functions used to initialize Karel Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
2a30414ac8
commit
4f9d29914a
1 changed files with 51 additions and 20 deletions
71
interface.md
71
interface.md
|
@ -4,13 +4,13 @@
|
||||||
## Primitives
|
## Primitives
|
||||||
|
|
||||||
- `step :: Karel -> Karel`<br>
|
- `step :: Karel -> Karel`<br>
|
||||||
Moves Karel one intersection forward
|
Moves Karel one intersection forward.
|
||||||
- `turnLeft :: Karel -> Karel`<br>
|
- `turnLeft :: Karel -> Karel`<br>
|
||||||
Pivots Karel 90 degrees left
|
Pivots Karel 90 degrees left.
|
||||||
- `pickBeeper :: Karel -> Karel`<br>
|
- `pickBeeper :: Karel -> Karel`<br>
|
||||||
Takes a beeper from the current intersection and puts it in the beeper bag
|
Takes a beeper from the current intersection and puts it in the beeper bag.
|
||||||
- `putBeeper :: Karel -> Karel`<br>
|
- `putBeeper :: Karel -> Karel`<br>
|
||||||
Takes a beeper from the beeper bag and puts it at the current intersection
|
Takes a beeper from the beeper bag and puts it at the current intersection.
|
||||||
|
|
||||||
|
|
||||||
## Sensors
|
## Sensors
|
||||||
|
@ -18,11 +18,40 @@
|
||||||
- `frontIsClear :: Karel -> Bool`<br>
|
- `frontIsClear :: Karel -> Bool`<br>
|
||||||
Returns `True` if there is no wall directly in front of Karel. Returns `False` if there is a wall.
|
Returns `True` if there is no wall directly in front of Karel. Returns `False` if there is a wall.
|
||||||
- `beepersPresent :: Karel -> Bool`<br>
|
- `beepersPresent :: Karel -> Bool`<br>
|
||||||
Returns `True` if Karel is standing at an intersection that has a beeper, `False` otherwise
|
Returns `True` if Karel is standing at an intersection that has a beeper, `False` otherwise.
|
||||||
|
- `facing :: Direction -> Karel -> Bool`<br>
|
||||||
|
Returns `True` if Karel is facing queried direction, `False` otherwise.
|
||||||
- `facingNorth :: Karel -> Bool`<br>
|
- `facingNorth :: Karel -> Bool`<br>
|
||||||
Returns `True` if Karel is facing north, `False` otherwise
|
Returns `True` if Karel is facing north, `False` otherwise.
|
||||||
- `beepersInBag :: Karel -> Bool`<br>
|
- `beepersInBag :: Karel -> Bool`<br>
|
||||||
Returns `True` if there is at least one beeper in Karel's beeper bag, `False` if the beeper bag is empty
|
Returns `True` if there is at least one beeper in Karel's beeper bag, `False` if the beeper bag is empty.
|
||||||
|
|
||||||
|
## Creating world
|
||||||
|
|
||||||
|
- `worldWithDimensions :: Vector -> World`<br>
|
||||||
|
Takes a pair of integers, specifying dimensions of a world `(width, height)` and
|
||||||
|
returns new world.
|
||||||
|
- `setBeepersAt :: Vector -> Int -> World -> World`<br>
|
||||||
|
Sets beepers at specified position, if beepers = 0 => removes them, negative count
|
||||||
|
or position not in the world results in error.
|
||||||
|
- `addWallAt :: Vector -> Direction -> World -> World`<br>
|
||||||
|
Adds wall at specified position to specified direction, if position is not in the
|
||||||
|
world, results in error.
|
||||||
|
- `removeWallAt :: Vector -> Direction -> World -> World`<br>
|
||||||
|
Removes wall at specified position to specified direction, if position is not in
|
||||||
|
the world, results in error.
|
||||||
|
|
||||||
|
## Creating Karel
|
||||||
|
|
||||||
|
- `defaultKarel :: World -> Karel`<br>
|
||||||
|
Creates Karel instance with a given world. Karel is defaultly placed at (1, 1),
|
||||||
|
facing East with no beepers in his bag.
|
||||||
|
- `initialPosition :: Vector -> Karel -> Karel`<br>
|
||||||
|
Sets Karel's initial position, if position is out of the world, results in error.
|
||||||
|
- `initialDirection :: Direction -> Karel -> Karel`<br>
|
||||||
|
Sets Karel's initial direction.
|
||||||
|
- `initialBeepersInBag :: Int -> Karel -> Karel`<br>
|
||||||
|
Sets Karel's initial beepers in bag, if negative number is given, results in error.
|
||||||
|
|
||||||
# Super Karel Language Reference
|
# Super Karel Language Reference
|
||||||
|
|
||||||
|
@ -33,29 +62,31 @@ Super Karel is an extension to the basic Karel the Karel library. Super Karel is
|
||||||
- `frontIsBlocked :: Karel -> Bool`<br>
|
- `frontIsBlocked :: Karel -> Bool`<br>
|
||||||
Returns `True` if there is a wall directly in front of Karel, `False` otherwise.
|
Returns `True` if there is a wall directly in front of Karel, `False` otherwise.
|
||||||
- `leftIsClear :: Karel -> Bool`<br>
|
- `leftIsClear :: Karel -> Bool`<br>
|
||||||
Returns `True` if there is no wall immediately to Karel's left, `False` if there is
|
Returns `True` if there is no wall immediately to Karel's left, `False` if there is.
|
||||||
- `leftIsBlocked :: Karel -> Bool`<br>
|
- `leftIsBlocked :: Karel -> Bool`<br>
|
||||||
Returns `True` if there is a wall immediately to Karel's left, `False` otherwise
|
Returns `True` if there is a wall immediately to Karel's left, `False` otherwise.
|
||||||
- `rightIsClear :: Karel -> Bool`<br>
|
- `rightIsClear :: Karel -> Bool`<br>
|
||||||
Returns `True` if there is no wall immediately to Karel's right, `False` if there is
|
Returns `True` if there is no wall immediately to Karel's right, `False` if there is.
|
||||||
- `rightIsBlocked :: Karel -> Bool`<br>
|
- `rightIsBlocked :: Karel -> Bool`<br>
|
||||||
Returns `True` if there is a wall immediately to Karel's right, `False` otherwise
|
Returns `True` if there is a wall immediately to Karel's right, `False` otherwise.
|
||||||
- `no_beepers_present :: Karel -> Bool`<br>
|
- `no_beepers_present :: Karel -> Bool`<br>
|
||||||
Returns `True` if there is not beeper at the current intersection, `False` if there is a beeper at the current intersection
|
Returns `True` if there is not beeper at the current intersection, `False` if there is a beeper at the current intersection.
|
||||||
|
- `notFacing :: Direction -> Karel -> Bool`<br>
|
||||||
|
Returns `True` if Karel is not facing queried direction, `False` if he is facing north.
|
||||||
- `notFacingNorth :: Karel -> Bool`<br>
|
- `notFacingNorth :: Karel -> Bool`<br>
|
||||||
Returns `True` if Karel is not facing north, `False` if he is facing north
|
Returns `True` if Karel is not facing north, `False` if he is facing north.
|
||||||
- `facingSouth :: Karel -> Bool`<br>
|
- `facingSouth :: Karel -> Bool`<br>
|
||||||
Returns `True` if Karel is facing south, `False` otherwise
|
Returns `True` if Karel is facing south, `False` otherwise.
|
||||||
- `notFacingSouth :: Karel -> Bool`<br>
|
- `notFacingSouth :: Karel -> Bool`<br>
|
||||||
Returns `True` if Karel is not facing south, `False` if he is facing south
|
Returns `True` if Karel is not facing south, `False` if he is facing south.
|
||||||
- `facingEast :: Karel -> Bool`<br>
|
- `facingEast :: Karel -> Bool`<br>
|
||||||
Returns `True` if Karel is facing east, `False` otherwise
|
Returns `True` if Karel is facing east, `False` otherwise.
|
||||||
- `notFacingEast :: Karel -> Bool`<br>
|
- `notFacingEast :: Karel -> Bool`<br>
|
||||||
Returns `True` if Karel is not facing east, `False` if he is facing east
|
Returns `True` if Karel is not facing east, `False` if he is facing east.
|
||||||
- `facingWest :: Karel -> Bool`<br>
|
- `facingWest :: Karel -> Bool`<br>
|
||||||
Returns `True` if Karel is facing west, `False` otherwise
|
Returns `True` if Karel is facing west, `False` otherwise.
|
||||||
- `notFacingWest :: Karel -> Bool`<br>
|
- `notFacingWest :: Karel -> Bool`<br>
|
||||||
Returns `True` if Karel is not facing west, `False` if he is facing west
|
Returns `True` if Karel is not facing west, `False` if he is facing west.
|
||||||
- `noBeepersInBag :: Karel -> Bool`<br>
|
- `noBeepersInBag :: Karel -> Bool`<br>
|
||||||
Returns `True` if Karel's beeper bag is empty, `False` if there is at least one beeper in the beeper bag
|
Returns `True` if Karel's beeper bag is empty, `False` if there is at least one beeper in the beeper bag.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue