1 / 14

Logo -- A Language for Learning

Logo -- A Language for Learning. Liping Cai 11/21/2005. Agenda. What is Logo? History Syntax and Example Demo Reference . What is Logo?. Designed to manipulate language – Words and Sentences. Designed to introduce children to programming concepts

benjamin
Télécharger la présentation

Logo -- A Language for Learning

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Logo -- A Language for Learning Liping Cai 11/21/2005

  2. Agenda • What is Logo? • History • Syntax and Example • Demo • Reference

  3. What is Logo? • Designed to manipulate language – Words and Sentences. • Designed to introduce children to programming concepts • Intended to be easy to learn, easy to use, easy to read, but also powerful and able to cope with complex problems. • Features: modularity, extensibility, interactivity, and flexibility • Areas of Application: Graphics (Turtle Graphics), Use with Language, Making Music

  4. History • The first version of Logo is created in 1967 by Seymour Papert and his team. • Throughout the 1970s Logo was incubating at MIT and a few other research sites. • Widespread use of Logo began with the advent of personal computers during the late 1970s. • the Logo boom is in the early 1980s but Logo did not become popular among applications programmers. • Over the past few years there has been a flurry of new Logo development accompanied by renewed public awareness and enthusiasm. • MicroWorlds. Released in 1993 by LCSI. MicroWorlds includes many extra-Logo features - drawing tools, a shape editor, a melody maker, the ability to import graphics and sounds - that work along with Logo to support the creation of multimedia projects, games, and simulations. • Logo has also been incorporated into HyperStudio, the widely popular multimedia program for Macintosh and Windows from Roger Wagner Productions.

  5. Get to Know Logo • Turtle: Cursor for Logo -- set position of the logo: Turtle Screen Positions using <Setxy horizontal vertical> • Technical Terms: -- instruction: is what you type to Logo to tell it to do something. Print 17 is an example of an instruction. -- procedure: is a small piece of code that performs a single task ;Procedures are invoked by instructions. Print is a procedure. -- command: is a procedure that does not output a value but instead has some effect such as printing something on the screen, moving a turtle, or making a sound. Print is a command; -- operation: is a procedure that computes a value and outputs it. Sum and product are operations.

  6. Simple Commands • Forward 100 - moves the turtle forward 100 unit • Back 50 - moves the turtle back 50 units • Right 45 - turns the turtle 45 degrees to the right • Left 90 - turns the turtle 90 degrees to the left • Home - Returns the turtle to its origin • ClearSceen - Erases the screen • repeat 4 [FD 100 RT 90] – draw a square • Print “hello – print Hello on the screen

  7. primitive operations • Sum: Print Sum 2 3 – 5 • First: Print first “Hello – H; Print first [How are you?] – How • Butfrist: Print butfirst “hello – ello; Print butfirst [how are you?] – are you? • Item: Print item 3 “ how – w; Print item 3 [How are you] – you • Sentence: print sentence "hello "goodbye -- hello goodbye print sentence [this is] [a test] -- this is a test; print sentence "this [is one too] -- this is one too; print sentence [] [list of words] – list of words; • Word: print word "now "here – nowhere; print word "this [is a test] -- word doesn't like [is a test] as input • List: print list [this is] [a test] -- [this is] [a test]; print list "this [is one too] -- this [is one too]; print list [] [list of words] -- [] [list of words] ;

  8. Define Procedures & Variables: • To define a procedure: To procedure …. Statements End • To define a variable: MAKE "<variableName> <value> eg make "size 10. In this example the variable called "size" will now have a value of ten. make "position {1 2 3 4 5 6 7 8 9} -- make an array • Using variable in Procedure: colon(:) in front of variable name. to numberingmake "size 10label :sizeend

  9. Predicates & Operator: • A predicate is an operation whose output is always either the word true or the word false. Listp -- return true if input is a list, false if not. print wordp "hello – true; print wordp [hello] – false print emptyp []-- true; print emptyp 0 –false print equalp 3 3.0-- true; print equalp "hello [hello]--false • Define custom Predicates: to vowelp :letter output memberp :letter [a e i o u] end print vowelp “e – true; print vowelp “h – false. • Operators: + - * /

  10. Conditional Commands & Iteration • If: if equalp 2 1+1 [print "Yup.] – Yup. • ifelse: ifelse 4 = 2+2 [print "Yup.] [print "Nope.] -- Yup • iftrue and iffalse : make "variable1 27make "variable2 33test :variable1 = :variable2iftrue [print [The values are the same.]]ifffalse [print [The values are different.]]  --The values are different. • Until, while : until [condition][action]; while [condition][action] until [:count > 10][print :count  make "count  :count + 1] -- 1 2 3 4 5 6 7 8 9 10 where [:count < 10][print :count  make "count  :count + 1] -- 1 2 3 4 5 6 7 8 9 • Do.until, do.while : do.until [action][condition] do.while [action][condition] do.until [print :count  make "count  :count + 1][:count > 10] --1 2 3 4 5 6 7 8 9 10 do.while [print :count  make "count  :count + 1][:count < 10]--1 2 3 4 5 6 7 8 9

  11. Conditional Commands & Iteration (Continued) • For: for [variable_name starting_value limit_value, steps] for [number 4 7] [print :number] – 4 5 6 7 for [value 4 11 3] [print :value] -- 4 7 1 0 • Foreach : take each element in the list foreach [chocolate [rum raisin] pumpkin] [print sentence [I like] ?] -- I like chocolate I like rum raisin I like pumpkin • Map : collect the results of doing this for each of those • Macro: Berkeley Logo includes this mechanism, no other version has Macro, Like Lisp.

  12. Recursion(Graphic Example) to tree :size if :size < 5 [forward :size back :size stop] forward :size/3 left 30 tree :size*2/3 right 30 forward :size/6 right 25 tree :size/2 left 25 forward :size/3 right 25 tree :size/2 left 25 forward :size/6 back :size End Tree 100

  13. References • http://www.cs.berkeley.edu/~bh/v1-toc2.html Symbolic Computing, a Logo programming text that concentrates on natural language processing rather than the graphics most people associate with Logo. • http://www.cs.berkeley.edu/~bh/v2-toc2.html Advanced Techniques, in which discussions of more advanced Logo features alternate with sample projects using those features, with commentary on the structure and style of each. • http://www.cs.berkeley.edu/~bh/v3-toc2.html Beyond Programming, brief introductions to six college-level computer science topics.

  14. More References • http://library.advanced.org/18446/eindex.shtml • Star Logo Home Page http://el.www.media.mit.edu/groups/el/projects/starlogo/ • The Logo Foundation http://lcs.www.media.mit.edu/groups/logo-foundation/ • Download a FREE version of MSW Logo http://www.softronix.com • Links to all sorts of Logo Resources http://lcs.www.media.mit.edu/groups/logo-foundation/links.html

More Related