Commands
Robotlang evolved (And is continuing to evolve) over several months so not all commands were implemented at once. This is a quickreference to currently implemented commands.
Jump to: Lists | Arithmetic | Boolean Operations | Language Constructs | Processes | Robotics
- List Manipulation
-
- car
-
- Takes the head of a list
- (car expr) -> (car expr)
- (car (1 2 3)) -> 1
- cdr
-
- Takes the tail of a list
- (cdr expr) -> (cdr expr)
- (cdr (1 2 3)) -> (2 3)
- cons
-
- Joins two lists
- (cons expr1 expr2) -> (expr1 expr2)
- (cons (+ 1 2) (3 4)) -> (+ 1 2 3 4)
- Arithmetic Operators
-
- +
-
- Adds its argument
- (+ expr1 expr2 ... exprn)
- (+ 1 2 3) -> 6
- -
-
- Additional arguments subtracted from the first argument
- (- expr1 expr2 ... exprn)
- (- 10 2 3) -> 5
- [Warning] Negative numbers not currently supported...
- *
-
- Multiplies all elements in the list
- (* expr1 expr2 ... exprn)
- (* 10 2) -> 20
- Boolean Operations
-
- #t / #f
-
- #t and #f are the constants true and false in robotlang.
- >
-
- Compares values (is the first arg greater than the second?)
- (> 10 2) -> #t)
- [Warning] Must take 2 parameters
- <
-
- Compares values (is the first arg less than the second?)
- (< 12 1) -> #f)
- [Warning] Must take 2 parameters
- eq?
-
- Compares two values for equality
- (eq? 12 (+ 10 2)) -> #t)
- [Warning] Must take 2 parameters
- [Warning] Comparing lists doesn't work...
- bool?
-
- Checks the argument is a boolean
- (bool? 10) -> #f)
- [Warning] Must take 1 parameter
- num?
-
- Checks the argument is a number
- (bool? 10) -> #t)
- [Warning] Must take 1 parameter
- Basic Language Constructs
-
- if
-
- Basic if statement with boolean condition, what to do if true and what to do if false
- (if condition resulttrue resultfalse)
- (if (eq? 10 2) 1 (+ 1 2 3)) -> 6
- cond
-
- Cond statement, for multiple boolean conditions and results
- (cond (condition1 result1) (condition2 result2) ... (conditionn resultn))
- (cond ((eq? 10 2) (+ 1 2 3)) (#f 2) (#t 10)) -> 10
- lambda
-
- lambda functions
- (lambda (param1 param2...paramn) expr)
- ((lambda (x y) (+ x y 1)) 10) -> 11
- [Note] Multiple arguments to lambda functions are allowed
- letrec
-
- letrec, for recursive function definition
- (letrec (definition1 definition2 ... definitionn) (expression))
- (letrec ( ((even? n) (if (eq? 0 n) #t (odd? (- n 1)))) ((odd? n) (if (eq? 0 n) #f (even? (- n 1)))) ) (even? 88)) -> #t
- Process manipulation
-
- spawn
-
- Spawns off a new erlang-like process
- (spawn process)
- (spawn (+ 1 2 3)) -> i/o
- [Warning] Implementation may change
- send
-
- Sends a message to the process indicated by the PID
- (send recipientPID message)
- (send !2 42) -> Sends message "42" to process 2
- [Warning] Behaviour is undefined if the recipient process does not exist...
- receive
-
- Consumes a message from the processes mailbox, blocks if there are no messages
- receive
- (+ receive 2 3) [with the message 1 in the mailbox] -> (+ 1 2 3)
- [Note] Will block if there are no messages in the mailbox
- Robotics Interaction
-
- rmove
-
- Takes a trio of arguments and tells a (Player) robot to change course
- (rmove speedforward speedsideways speedrotational)
- (rmove 10 10 10) -> Robot moves round in circles at a rate of 10 units per second
- rpos
-
- Returns the robots current position and rotation
- rpos
- (rpos) -> (positionx positiony rotation)
- [Note] This will probably change in the future (Possibly split into three seperate functions for getting position)
- rlas
-
- Reads data from the laser rangefinder
- rlas
- rlas -> Details from the laser
- [Note] Laser is statically set to scan a certain area rather than configurable - this ought to change in a later version to allow for more complex / flexible programs