Top Banner
Terrapin Logo Terrapin Logo "Logo is the name for a philosophy of education and a continually "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its evolving family of programming languages that aid in its realization." realization." - Harold Abelson - Harold Abelson Apple Logo, Apple Logo, 1982 1982 Alex Veremeychik Alex Veremeychik Mike Adams Mike Adams
26

Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

Dec 23, 2015

Download

Documents

Brook Matthews
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

Terrapin LogoTerrapin Logo"Logo is the name for a philosophy of education and a continually "Logo is the name for a philosophy of education and a continually

evolving family of programming languages that aid in its evolving family of programming languages that aid in its realization."realization."

- Harold Abelson- Harold Abelson    Apple Logo,Apple Logo, 1982 1982

Alex VeremeychikAlex Veremeychik

Mike AdamsMike Adams

Page 2: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

HistoryHistory

Terrapin Software company was founded Terrapin Software company was founded in 1977 to market the turtle robot.in 1977 to market the turtle robot.

Introduced it’s first computer version on Introduced it’s first computer version on the Apple II.the Apple II.

Logo was originally created by Seymore Logo was originally created by Seymore Papert at MIT in 1967.Papert at MIT in 1967.

Designed on top of Lisp as a tool for Designed on top of Lisp as a tool for learning.learning.

Page 3: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

Who is Terrapin Logo for?Who is Terrapin Logo for?

Terrapin Logo was primarily designed for Terrapin Logo was primarily designed for K-12 students.K-12 students.

Adaptable for all ages.Adaptable for all ages.

Anyone who’s interested in programming Anyone who’s interested in programming graphical patters or recursive visual graphical patters or recursive visual algorithms.algorithms.

Page 4: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

Terrapin Logo IntroductionTerrapin Logo Introduction

It’s most noticeable feature is the turtle, a It’s most noticeable feature is the turtle, a triangular cursor used for drawing triangular cursor used for drawing patterns.patterns.

It’s intuitive and has easily understandable It’s intuitive and has easily understandable commands. Such as RIGHT, LEFT, commands. Such as RIGHT, LEFT, FORWARD, and BACKWARDS.FORWARD, and BACKWARDS.

Page 5: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

Introduction ContinuedIntroduction Continued

The top half, The top half, “Graphics”, is used “Graphics”, is used for execution of for execution of programs or programs or commands.commands.

The bottom half, The bottom half, “Listener”, is used to “Listener”, is used to input commands or input commands or create functions.create functions.

Page 6: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

Language FeaturesLanguage Features

ProceduralProceduralResponsiveResponsiveCan be both interactive and notCan be both interactive and notMulti-threadedMulti-threadedCan draw graphics and play soundsCan draw graphics and play soundsLimited RCX commands and featuresLimited RCX commands and featuresCan implement new Logo-level RCX Can implement new Logo-level RCX commands with knowledge of RCX OP-commands with knowledge of RCX OP-codescodes

Page 7: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

More featuresMore features

Not case sensitiveNot case sensitive

Strings are denoted by double quotes in front of Strings are denoted by double quotes in front of the string.the string. Print “HelloPrint “Hello

HELLOHELLO

There are 5 basic types of data:There are 5 basic types of data: Words, Numbers, Lists, Property Lists, and ArraysWords, Numbers, Lists, Property Lists, and Arrays

There are 3 types of objects:There are 3 types of objects: Turtles, Bitmaps, and ControlsTurtles, Bitmaps, and Controls

Page 8: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

WordsWords

Any group of characters including letters, numbers, and Any group of characters including letters, numbers, and punctuation marks that does not contain a space and is punctuation marks that does not contain a space and is not a primitive or procedure.not a primitive or procedure.

WORD? “HelloWORD? “HelloResult: TRUEResult: TRUE

WORD? “123GOWORD? “123GOResult: TRUEResult: TRUE

Numbers in Logo are a special class of words, that have Numbers in Logo are a special class of words, that have special primitives to deal with them.special primitives to deal with them.Names of all procedures in Logo, including primitive Names of all procedures in Logo, including primitive procedures, are words, although numbers cannot be procedures, are words, although numbers cannot be used as the name of procedures.used as the name of procedures.

Page 9: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

NumbersNumbers

A number can be an integer, a decimal, or a number in A number can be an integer, a decimal, or a number in exponential notation.exponential notation. 3, 26, 4.7, 12E-73, 26, 4.7, 12E-7

Valid numbers range from 1E-308 to 1E308.Valid numbers range from 1E-308 to 1E308.All calculations in Logo have a precision of 15 digits.All calculations in Logo have a precision of 15 digits.Logo expresses number in the range between .000001 Logo expresses number in the range between .000001 to 1000000 in decimal notation and anything smaller or to 1000000 in decimal notation and anything smaller or larger in scientific notation.larger in scientific notation.Can interpret both prefix and infix notation.Can interpret both prefix and infix notation.

+ 2 2 is the same as 2 + 2+ 2 2 is the same as 2 + 2

Does correct order of operations.Does correct order of operations.

Page 10: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

ListsLists

A list is information in Logo enclosed in square brackets.A list is information in Logo enclosed in square brackets. LIST? [ 1 2 3 ]LIST? [ 1 2 3 ]

Result: TRUEResult: TRUE

Empty list is a list with no elements. Ex. [ ]Empty list is a list with no elements. Ex. [ ]

Lists within lists are allowed.Lists within lists are allowed. LIST? [ [RED BLUE] [ORANGE GREEN] [BLACK YELLOW] ]LIST? [ [RED BLUE] [ORANGE GREEN] [BLACK YELLOW] ]

Result: TRUEResult: TRUE

Some additional commands:Some additional commands: EQUAL?, NAME, THING, WORD, ITEM, LAST, FIRST, EQUAL?, NAME, THING, WORD, ITEM, LAST, FIRST,

EMPTY?, NUMBER?, CHAREMPTY?, NUMBER?, CHAR

Page 11: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

Property ListsProperty Lists

Special type of list that allows assignment of Special type of list that allows assignment of multiple values to a single object in Logo.multiple values to a single object in Logo.Syntax:Syntax: name [property1 value1 propery2 value2 …]name [property1 value1 propery2 value2 …]Example:Example: DOG [BREED DOBERMAN HEIGHT [14 INCHES] DOG [BREED DOBERMAN HEIGHT [14 INCHES]

COLOR [BLACK] ]COLOR [BLACK] ]

Visible Logo objects like, Turtles, Bitmaps and Visible Logo objects like, Turtles, Bitmaps and Controls, all have properties assigned to them, Controls, all have properties assigned to them, which can be edited through property lists.which can be edited through property lists.

Page 12: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

ArraysArrays

Special type of Logo object designed for efficient storage Special type of Logo object designed for efficient storage of structured information.of structured information.

Mostly thought of as tabular forms of information with Mostly thought of as tabular forms of information with multiple rows and columns.multiple rows and columns.

For example a calendar can be thought of as an array. For example a calendar can be thought of as an array. You can write information to any particular day with three You can write information to any particular day with three dimensions, year, month, and day.dimensions, year, month, and day.

A special type of array is the A special type of array is the bytearraybytearray, which can be , which can be used to store numerical information where each element used to store numerical information where each element is a number between 0 and 255.is a number between 0 and 255.

Page 13: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

TurtlesTurtles

A special type of graphics cursor.A special type of graphics cursor.

The turtle cursor carries a pen which can draw The turtle cursor carries a pen which can draw lines through commands issued in the listener lines through commands issued in the listener window.window.

The turtle can be controlled through commands The turtle can be controlled through commands such as: FORWARD, BACKWARDS, RIGHT, such as: FORWARD, BACKWARDS, RIGHT, LEFT, PENUP, PENDOWN, and TOWARD.LEFT, PENUP, PENDOWN, and TOWARD.

Page 14: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

BitmapsBitmaps

Exactly what you think it is.Exactly what you think it is.

An image which you can place anywhere in the An image which you can place anywhere in the Graphics window.Graphics window.

The main difference between Bitmaps and The main difference between Bitmaps and Turtles, is that turtles can draw and are of only a Turtles, is that turtles can draw and are of only a single color, reflecting their pen color.single color, reflecting their pen color.

Turtles visually reflect their heading, while Turtles visually reflect their heading, while bitmaps do not change visually when their bitmaps do not change visually when their heading is changed.heading is changed.

Page 15: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

ControlsControls

Objects for obtaining input from the users for Objects for obtaining input from the users for your program.your program.A typical Control would be a push-button that A typical Control would be a push-button that you can click.you can click.You determine the size and position of the You determine the size and position of the Control as well as what happens when the user Control as well as what happens when the user interacts with the Control.interacts with the Control.Other examples of Controls are:Other examples of Controls are: Check boxes, scroll bars, pop-up menus, edit fields, Check boxes, scroll bars, pop-up menus, edit fields,

and list boxes.and list boxes.

Page 16: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

VariablesVariables

Typical global and local variables.Typical global and local variables.To declare local variables use LOCALTo declare local variables use LOCAL LOCAL “SALUTATION [HOW ARE YOU?]LOCAL “SALUTATION [HOW ARE YOU?]

PRINT :SALUTATIONPRINT :SALUTATION

HOW ARE YOU?HOW ARE YOU?

To declare global variables use MAKE or NAMETo declare global variables use MAKE or NAME MAKE “GREETING “HELLOMAKE “GREETING “HELLO

PRINT :GREETINGPRINT :GREETINGHELLOHELLO

NAME “HELLO “GREETINGNAME “HELLO “GREETINGPRINT :GREETINGPRINT :GREETING

HELLOHELLO

Page 17: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

FunctionsFunctions

Created using the TO keyword.Created using the TO keyword.TO SQUARETO SQUARE

REPEAT 4 [ FORWARD 50 RIGHT 90 ]REPEAT 4 [ FORWARD 50 RIGHT 90 ]

To pass parameters just place them after the To pass parameters just place them after the definition.definition.TO SQUARE LENGTHTO SQUARE LENGTH

REPEAT 4 [ FD LENGTH RT 90 ]REPEAT 4 [ FD LENGTH RT 90 ]

Page 18: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

ConditionalsConditionals

IFIF IF expression [then-instructions] IF expression [then-instructions] 

IF expression [then-instructions] [else-instructions] IF expression [then-instructions] [else-instructions] IF expression THEN instructions IF expression THEN instructions 

IF expression THEN instructions ELSE instructionsIF expression THEN instructions ELSE instructions TEST (has to be issued before IFTRUE and IFFALSE)TEST (has to be issued before IFTRUE and IFFALSE)

TEST statementTEST statement

IFTRUEIFTRUE IFTRUE instructionlistIFTRUE instructionlist

IFFALSEIFFALSE IFFALSE instructionlistIFFALSE instructionlist

Page 19: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

LoopsLoops

REPEAT, FOR, EACH, FOREACH, WHILEREPEAT, FOR, EACH, FOREACH, WHILE REPEAT number listREPEAT number list

REPEAT 5 PRINT [HELLO WORLD] ] REPEAT 5 PRINT [HELLO WORLD] ]

FOR word number number runlist FOR word number number runlist FOR "I 1 4 [PRINT :I] FOR "I 1 4 [PRINT :I]

EACH listEACH listEACH [SETH WHO * 360 / 16]EACH [SETH WHO * 360 / 16]

EACH is controlled by WHO, and typically used for turtlesEACH is controlled by WHO, and typically used for turtles

FOREACH list runlistFOREACH list runlistFOREACH [JOHN MARTHA] [print "?]FOREACH [JOHN MARTHA] [print "?]

WHILE testlist runlistWHILE testlist runlistMAKE "X 1 MAKE "X 1 WHILE [:X < 5] [PRINT :X MAKE "X :X + 1] WHILE [:X < 5] [PRINT :X MAKE "X :X + 1]

Page 20: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

Multiple TurtlesMultiple Turtles

16 possible turtles can be used at the 16 possible turtles can be used at the same timesame time

CS TELLALL 0 15 SHOWTURTLECS TELLALL 0 15 SHOWTURTLE

EACH [SETH WHO * 360 / 16]EACH [SETH WHO * 360 / 16] ;set direction;set direction

EACH [FORWARD 8 * WHO] EACH [FORWARD 8 * WHO] ;move based on ;move based on idid

Page 21: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

More TurtlesMore Turtles

Turtles follow each other.Turtles follow each other.TO SETUPTO SETUPCS SETTURTLES 4CS SETTURTLES 4TELL 0 PU SETXY [ 100 100 ]TELL 0 PU SETXY [ 100 100 ] ;pen up;pen upTELL 1 PU SETXY [ -100 100 ]TELL 1 PU SETXY [ -100 100 ]TELL 2 PU SETXY [ -100 -100 ]TELL 2 PU SETXY [ -100 -100 ]TELL 3 PU SETXY [ 100 -100 ]TELL 3 PU SETXY [ 100 -100 ]TELL ALLTURTLES ST PDTELL ALLTURTLES ST PD ;set pen down;set pen down

TO CHASE TO CHASE ASK 0 [SETH TOWARDS ASK 1 [GETXY] FD 1]ASK 0 [SETH TOWARDS ASK 1 [GETXY] FD 1] ;FOLLOW 1;FOLLOW 1ASK 1 [SETH TOWARDS ASK 2 [GETXY] FD 1] ;FOLLOW 2ASK 1 [SETH TOWARDS ASK 2 [GETXY] FD 1] ;FOLLOW 2ASK 2 [SETH TOWARDS ASK 3 [GETXY] FD 1]ASK 2 [SETH TOWARDS ASK 3 [GETXY] FD 1] ;FOLLOW 3;FOLLOW 3ASK 3 [SETH TOWARDS ASK 0 [GETXY] FD 1]ASK 3 [SETH TOWARDS ASK 0 [GETXY] FD 1] ;FOLLOW 0;FOLLOW 0CHASECHASE

Page 22: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

RCX CommandsRCX Commands

To start communication with RCXTo start communication with RCX RCX.OPEN portRCX.OPEN port

RCX.OPEN “USBRCX.OPEN “USB

Motor controlMotor control MOTOR number-or-list powerMOTOR number-or-list power

MOTOR number-or-list power durationMOTOR number-or-list power duration

MOTOR number-or-list power “FALSEMOTOR number-or-list power “FALSE

Stop RCX executionStop RCX execution RCX.HALTRCX.HALT

Close communicationClose communication RCX.CLOSERCX.CLOSE

Page 23: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

RCX SensorsRCX Sensors

Set sensor typeSet sensor type SETSENSOR number typeSETSENSOR number type

SETSENSOR number type datatypeSETSENSOR number type datatype

SETSENSOR number type datatype slopeSETSENSOR number type datatype slope Type can be SWITCH, TEMP, LIGHT, ANGLEType can be SWITCH, TEMP, LIGHT, ANGLE

:SENSORn is a built in variable for the sensor ports :SENSORn is a built in variable for the sensor ports where n is 1-3.where n is 1-3.

To read a sensor simply type .SENSORn and the value To read a sensor simply type .SENSORn and the value will be displayed in the Listener window.will be displayed in the Listener window.

Page 24: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

RCX LimitationsRCX Limitations

Logo does not provide full built-in support Logo does not provide full built-in support for the RCX.for the RCX.

If you are familiar with the RCX byte codes If you are familiar with the RCX byte codes you can directly program the RCX you can directly program the RCX with .RCX list.with .RCX list.

.RCX list sends direct byte codes to the .RCX list sends direct byte codes to the RCX brick.RCX brick.

Page 25: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

Blind MovementBlind Movement

RCX.OPEN "USBRCX.OPEN "USBTO RUN.UNTIL.HITTO RUN.UNTIL.HITSETSENSOR 1 "SWITCHSETSENSOR 1 "SWITCH ;set touch sensor;set touch sensorMOTOR 3 65MOTOR 3 65 ;move forward at 65 speed;move forward at 65 speedWHILE [.SENSOR1 = 0] []WHILE [.SENSOR1 = 0] [] ;while we don’t hit anything;while we don’t hit anythingMOTOR 3 -50MOTOR 3 -50 ;when hit, reverse 50;when hit, reverse 50MOTOR 1 -25MOTOR 1 -25 ;turn slightly;turn slightlyWAIT 100WAIT 100 ;keep backing up;keep backing upMOTOR 1 25MOTOR 1 25 ;realign the wheels;realign the wheelsWAIT 5WAIT 5MOTOR 1 0MOTOR 1 0 ;turn off turning motor;turn off turning motorRUN.UNTIL.HITRUN.UNTIL.HIT ;recursively call self;recursively call self

Page 26: Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

ReferencesReferences

Terrapin Logo homepage:Terrapin Logo homepage: http://www.terrapinlogo.comhttp://www.terrapinlogo.com

Logo Foundation website:Logo Foundation website: http://el.media.mit.edu/logo-foundation/logo/http://el.media.mit.edu/logo-foundation/logo/

index.htmlindex.html

Terrapin Reference ManualTerrapin Reference Manual

Terrapin TutorialTerrapin Tutorial