MSW Logo List Processing Primitive Command Summary

Shortc Action ut cleartext ct clears the text screen prints the item (word, list or result) to the text print i pr i screen show i shows the item with " or [] as appropriate holds the item in buffer until print is encountered type i then prints all output i op returns the value of i to the calling procedure Constructors joins two items (words or lists) together with a sentence i i se i i space between (as a list) joins two items (words or letters) together with no word i i space (as a word) De-Constructors first i returns the first item of input (a word or list) returns everything but the first item of input (a butfirst i bf i word or list) last i returns the last item of input (a word or list) returns everything but the last item of input (a butlast i bl i word or list) item n i returns the nth item of i Conditional Tests when test returns "true" does commands and if (test) [commands] continues, otherwise continues ifelse (test) when test returns "true" does first commands and [commands] continues, when test returns "false" does second [commands] commands and continues test (test) sets flag to "true" or "false" iftrue [commands] checks flag before completing commands iffalse [commands] checks flag before completing commands Predicates (some more commonly used ones) returns true if inputs are equal, otherwise returns equalp i i false returns true if the first i is a member of the second memberp i i group i, otherwise returns false returns true if the input (word or list) is empty, emptyp i otherwise returns false numberp i returns true if the input is number, otherwise Commands

repeat 4 [fd 50 rt 90] will draw a square makes the turtle invisible (it will move much faster hideturtle ht when invisible) showturtle st makes the turtle visible clears the graphics screen and returns the turtle to clearscreen cs home position clean _ clears the screen but leaves the turtle where it is sends the turtle to home position but leaves the home _ drawing as is removes the list of commands from the cleartext ct commander window lifts the turtle's pen so it doesn't draw when penup pu moving puts the turtle's pen back down so it will draw pendown pd when moving penerase pe changes the pen to an eraser causes the pen to erase over existing lines.wordp i listp i - returns false returns true if the input is a word (not a list). otherwise returns false returns true if the input is a list (not a word). otherwise returns false Turtle Graphics Shortc Action ut forward n fd n moves the turtle forward n turtle steps backward n bk n moves the turtle backwards n turtle steps right n rt n turns the turtle right n degrees left n lt n turns the turtle left n degrees repeat _ eg. penreverse px otherwise draw returns the drawing version of the pen after penpaint _ erasing or reversing keeps the turtle from wrapping or going off the fence _ edge of the window keeps the turtle from wrapping and allows it to go window _ out of the window makes the turtle wrap around the screen when it wrap _ gets to one edge setpensize [n _ uses two values for pen size. height and width n] setscreencolosetsc [n sets screen background colour** Commands .

y coordinates given setx n or sety _ moves the turtle to x or y coordinates given n pos or xcor or _ outputs the x and y or x or y position of the turtle ycor Setheading n seth n sets the turtle's heading in degrees (0 is up) outputs the heading the turtle would have if facing towards [n n] _ x. to square :size sets a variable :size that can be variable_nam _ used in square e the number of times that a procedure has been repcount none repeated PERSPECTIVE none Switch to 3D mode LEFTROLL n none Rolls the turtle (on to his left side) by n degrees RIGHTROLL n none Rolls the turtle (on to his right side) by n degrees UPPITCH n none Pitches the turtle nose up by n degrees DOWNPITCH none Pitches the turtle nose up by n degrees n . to square defines the name of a procedure to to procedure _ teach logo commands edit _ takes you to the editor to edit a procedure procedure : eg.r [n n n] n n] setpencolor setpc sets pen colour** [n n n] [n n n] sets the colour** to fill with if the fill command is setfloodcolor setfc [n used floods the area where the turtle is with the [n n n] n n] flood colour Fill _ setpos [n n] _ moves the turtle to the x. y given eg.