to tub.right? :temperature if and (:temperature > 88) (:temperature < 102) [print [Just Right!]] [print [Not Right.]] end to decimalp :object output and (numberp :object) (pointp :object) end to pointp :object if emptyp :object [output "FALSE] if (first :object) = ". [output "TRUE] output pointp butfirst :object end to plot.arctan make "val -pi make "inc pi / 37.5 make "x -150 setx 150 setx :x plot.a :val end to plot.a :val if :x > 150 [stop] forward arctan :val sety 0 setx :x + 4 make "x :x + 4 make "val :val + :inc plot.a :val end to encode :word if emptyp :word [output "] output word secret first :word encode butfirst :word end to secret :character make "secret.code 5 + ascii :character if :secret.code > ascii "z [make "secret.code :secret.code - 26] output char :secret.code end to decode :word if emptyp :word [output "] output word crack first :word decode butfirst :word end to crack :character make "cracked.code (ascii :character= -5 if :cracked.code < ascii "a [make "cracked.code :cracked.code + 26] output char :cracked.code end to flag forward 50 repeat 3 [right 120 forward 25] back 50 end to wheel repeat 12 [flag left 30] end to vanish :object if emptyp :object [stop] print :object vanish butfirst :object end to draw repeat 10000 [make "xin paddle 0 make "yin paddle 1 make "xin int ((:xin * (300 / 190)) - 150) make "yin int ((:yin * (-200 / 144)) + 90) setheading towards list :xin :yin forward [amount * 0.1] if buttonp 0 [stop] if buttonp 1 [clean] end to amount output int sqrt ((abs :xin) * (abs :xin) + ((abs :yin) * (abs :yin))) end to coil print [Enter a small number.] make "previous 0 forward grow.number right 30 trap end to grow.number make "growth first readlist if :growth < :previous [throw "not.bigger] make "previous :growth output :growth end to trap catch "not.bigger [draw.coil] (print [Enter a number bigger than] :previous) trap end to draw.coil print [Enter a bigger number.] forward grow.number right 30 draw.coil end to my.message catch "error [interpret] (print "Oops! first butfirst error [!!!]) print [What do you want to do about that?] run readlist my.message end to interpret print [What next, boss?] run readlist interpret end to tri.spi :side if :side > 80 [stop] forward :side right 120 tri.spi (:side + 3) end to box.spi :side if and (:side > 80) (:side < 90) [pause] forward :side right 90 box.spi (:side + 5) end to box :side repeat 4 [forward :side right 90] end to plot.cosine setpc 2 make "val 0 make "x -150 make "inc (300 / 60) setx 150 setx -150 penup setpos list :x 90 pd setpc 1 plot.c :val end to plot.c :val if :x > 150 [stop] make "y (90 * (cos :val)) ; 90 makes plot visible setheading towards list :x :y setpos list :x :y make "x :x + :inc make "val :val + 6 plot.c :val end to saved make "disk.name defaultd end to restored setd :disk.name end to learn make "definition [[]] print [Enter expressions you would like saved in a procedure.] print [Enter erase to delete your last instruction.] read.lines print [Type Y to define procedure, any other key to abandon.] test lowercase readchar = "y iftrue [type [Name for procedure?] make "title first readlist define :title :definition] end to read.lines make "newline readlist if :newline = [end] [stop] if :newline = [erase] [delete] [run :newline make "definition lput :newline :definition] read.lines end to delete print sentence "Deleting last :definition make "definition butlast :definition end to balloon setpc 1 forward 40 right 90 setpc 2 repeat 36 [forward 5 left 10] left 90 setpc 1 back 40 print "balloon! end to degrees.cycle :vals if emptyp :vals [stop] (print [There are] degrees (run first :vals) [degrees in] first :vals radians.) make "vals butfirst :vals degrees.cycle :vals end to snow make "x random 150 * (first shuffle [1 -1]) make "y random 100 * (first shuffle [1 -1]) dot list :x :y snow end to nest.circles :sizes if emptyp :sizes [stop] repeat 36 [forward first :sizes left 10] nest.circles butfirst :sizes end to pent repeat 5 [forward 25 left 72] end to safety.circle :size catch "error [repeat 180 [forward :size right 2] show error end to begin.vowelp :wrd output memberp first :wrd [a e i o u] end to pig :wrd if begin.vowelp :wrd [output word :wrd "ay] [output pig word (butfirst :wrd) (first :wrd)] end to pig.latin :phrase if emptyp :phrase [output []] output sentence (pig first :phrase) (pig.latin butfirst :phrase) end to plaid wrap setpc 3 right 40 forward 10965 setpc 2 right 90 forward 5000 setpc 1 penup right 90 forward 6 pendown ht repeat 625 [forward 3 left 90 forward 1 right 90 back 3 left 90 forward 1 right 90] end to exchange :from :to :in if emptyp :in [output []] if (first :in) = :from [output fput :to exchange :from :to butfirst :in] [output sentence first :in exchange :from :to butfirst :in] end to triangle.text :string label "loop if emptyp :string [stop] print :string make "string butfirst :string go "loop end to countdown :n label "loop if :n < 0> [stop] type :n make "n (:n - 1) go "loop end to compass :n if memberp :n [0 90 180 270] [points] if (:n > 360) [stop] (type heading char 9) right 5 penup forward 25 pendown forward 5 penup back 30 compass :n + 5 end to points pu forward 40 if :n = 0 [turtletext "N] if :n = 90 [turtletext "E] if :n = 180 [turtletext "S] if :n = 270 [turtletext "W] setpos [0 0] end to star :size repeat 5 [forward :size left 217 forward :size left 71] end to coin1 if 1 = random 2 [print "heads] [print "tails] end to coin2 print if 1 = random 2 ["heads] ["tails] end to coin3 if 1 = random 2 [output "heads] output "tails end to coin4 if 1 = random 2 [type "heads] [type "tails] print [\ side up] end to coin5 test 1 = random 2 if 1 = random 1000000 [print [Landed on edge!] stop] iftrue [type "heads ] iffalse [type "tails ] print [\ side up] end to make.sentence :n :v print (sentence item ((random (count :n)) + 1) :n item ((random (count :v)) + 1) :v end to sketch forward 2 wait 10 if keyp [turn rc] sketch end to turn :way if ascii :way = 6 ; Right Arrow key [right 10] if ascii :way = 2 ; Left Arrow key [left 10] end to delay print [Any keystroke delays next number by a second.] print.out end to print.out if keyp [wait 60 sink rc] (type random 10 char 9) print.out end to sink :object end to count.stars make "number 1 + random 10 draw.stars :number print [How many stars?] label "back if keyp [make buffer readquote (if not numberp first :buffer [ern "buffer go "back] [go on])] [go "back] label "on if :number = :buffer [print "Right!] [print [Wrong! There are] :number] cs count.stars end to draw.stars :number if :number = 0> [stop] penup setpos list (random 100 * first shuffle [1 -1]) (random 70 * first shuffle [1 -1]) pendown star pu draw.stars :number - 1 end to star2 ; Five pointed star repeat 5 [forward 30 left 127 forward 30 left 70] end to mirror :word (print reverse :word "| :word end to reverse :word if emptyp :word [output "] output (word last :word reverse butlast :word) end to around.L :s repeat 360 [forward :s left 10 make "s :s + .01] end to square repeat 4 [forward 60 right 90] end to zip.zap setpos list random 150 * first shuffle random 100 * first shuffle zip.zap end to reflect :object if listp :object [print reverse.list :object] [print reverse :object] end to drawing.report make "x (-150) make "y 80 penup setpos list :x :y turtletext "drawing.circle draw.circle setpos list :x :y turtletext "circle.finished setheading 0 forward 10 end to draw.circle (local "x "y) make "x 10 make "y 50 penup setpos list :x :y setheading 90 pendown repeat 36 [forward 10 right 10] pu end to decimal.of.fraction :n local "inverse make "inverse 1 / :n if :n = 1 [stop] decimal.of.fraction :n - 1 (print ["1/] :n char 9 :inverse end to quiz print [Do you like chocolate chip cookies?] if "y = lowercase first readquote [print [I do too!]] [print [Wow, I have never met anyone who did not!] end to sketch.lpen forward 2 wait 10 if lpenp [turn.to lpen] sketch.lpen end to turn.to :position convert.x convert.y (print :position "= list :x :y) setheading towards list :x :y sketch.lpen end to convert.x make "x (first :position) * 7.5 - 150 end to convert.y make "y (last :position) * (-8) + 100 end to add.entry :item make "extensions lput :item :extensions end to say.hello print [Hello! What is your name?] make "answer readquote (print [Nice to meet you,] word :answer ". end to vowelp :object if memberp :object [a e i o u] [output "TRUE] [output "FALSE] end to decrement :name if not namep :name [print [Not a variable.]] if numberp thing :name [make :name (thing :name) - 1] end to bg.cycle :val ; Displays background colors if :val = 0 [print [Cycle complete.] setbg 0 stop] setbg :val (print [This is background color number] first screenfacts) wait 20000 ; 2 seconds on a 500-MHz PC bg.cycle :val - 1 end to inverse :n if not numberp :n [(print :n [is not a number.]) stop] (print "1\ / :n "= 1 / :n end to average :numbers make "total 0 add.up :numbers print :total / count :numbers end to add.up :list if emptyp :list [stop] make "total :total + first :list add.up butfirst :list end to weather print [What is the temperature today?] make "answer readquote if or (:answer < 50) (:answer > 80) [print [Hmm, sounds uncomfortable!]] [print [Sounds nice!]] end to Aurora output [Briar Rose] end to vowelp2 :object output memberp :object [a e i o u] end to coin output first shuffle [heads tails] end to add.up2 :list if emptyp :list [output 0] output (add.up butfirst :list) + (first :list) end to nautilus :size if (remainder :size 5) = 0 [pause] repeat 36 [forward :size right 10] right 15 nautilus :size + 0.5 end to pen output list item 4 turtlefacts item 5 turtlefacts end to halo :size repeat 36 [forward :size * 0.5 pu forward :size * 0.1 pd forward :size * 0.2 pu forward :size * 0.1 pd forward :size * 0.1 pu back :size right 10 pd] ht end to move.triangle clearscreen hideturtle repeat 36 [triangle penerase triangle pendown setpc 2 right 10] end to triangle40 repeat 3 [forward 40 right 120] end to moving.triangle clearscreen hideturtle penreverse repeat 26 [triangle triangle right 10] end to find.radius :n repeat 180 [forward :n left 2] make "radius (180 * :n) / (2 * pi) (print [Radius =] :radius left 90 forward radius end to last.part :name if memberp ". :name [make "readlist where] [(print :name [in wrong format.]) stop] make "r2 count :name output piece (:r1 + 1) :r2 :name end to remove :name if emptyp plist :name [stop] make "prop first plist :name run (sentence "remprop "quote :name "quote :prop) remove :name end to triangle :size repeat 3 [forward :size right 120] end to square2 :size repeat 4 [forward :size right 90] end to tri repeat 3 [right 120 forward 25] end to flag2 forward 50 tri back 50 end to average2 :list output (add.up :list) / (count :list) end to save.place make "place pos end to return setpos :place end to find.center :n repeat 180 [forward :n left 2] make "radius (180 * :n) (2 * pi) left 90 forward :radius show pos end to make.character :name make "abilities [strength intelligence wisdom dexterity constitution harisma] make "other [class hitpoints armorclass alignment level experience oldpieces] assign :abilities assign :other (print [You have given] :name [the following characteristics:] print plist :name end to assign :list if emptyp :list [stop] print word first :list "? make "value readlist pprop :name first :list :value assign butfirst :list end to cube :n output (product :n :n :n) end to draw.spinner :n if (:n > 330) [stop] penup right 15 forward 25 turtletext (word (int (:n / 36))) back 25 right 21 forward 25 pendown forward 5 penup back 30 draw.spinner :n + 36 end to spin repeat 72 * random 6 [right 5] repeat random 45 [right 5] print int (heading / 36) end to quiz2 print [Do you know any Martians?] if lowercase readchar = "y [print [Takes one to know one!]] [print [Me either!]] end to poly.cycle :n (print [Press any key to draw a] :n [sided figure.]) sink readchar cs repeat :n [forward 40 right (360 / :n)] if :n > 8 [stop] poly.cycle :n + 1 end to spi :side :angle :inc forward :side right :angle spi :side + :inc :angle :inc end to evenp :n if 0 = remainder :n 2 [output "TRUE] [output "FALSE] end to rep.spi :side :angle :inc repeat 200 [forward :side right :angle make "side :side + :inc] end to around.R :s repeat 360 [forward :s right 10 make "s :s + .01] end to use :what if memberp lowercase :what [green red yellow] [make "colornumber where make "state "pd] if "eraser = lowercase :what [make "state "pe] run (sentence "setpen "list "quote :state "quote :colornumber) end to while :condition :instr_list if "TRUE = run :condition [run :instr_list] [stop] while :condition :instr_list end to screen.facts print [] print [Screen Facts] print [] type [Background Color Number:\ ] print item 1 screenfacts type [Screen state:\ ] print item 2 screenfacts type [Split Size:\ ] print item 3 screenfacts type [Window State:\ ] print item 4 screenfacts type [Scrunch Ratio:\ ] print item 5 screenfacts type [Zoom Factor:\ ] print item 6 screenfacts (type [(X,Y) of Viewport Center:] (word "\( item 7 sf ", item 8 sf "\)) print [] type [Current Resolution Setting:\ ] print item 9 screenfacts print [] end to diagonal.type type readchar setcursor list (3 + first cursor) (1 + last cursor) diagonal.type end to draw.compass :n if :n > 330 [setheading 0 stop] penup setheading :n forward 50 turtletext (word :n) back 50 right 23 forward 45 pendown forward 5 penup back 50 drawcompass :n + 45 end to pc.cycle :penc :bkgr if :penc > 3 [change.bg] if :bkgr > 50 [stop] setpc :penc (print [This is pencolor] item 5 tf) repeat 36 [forward 4 right 10] back 20 wait 20000 ; 2 seconds on a 500-MHz PC pc.cycle (:penc + 1) :bkgr end to change.bg make "bkgr 16 + :bkgr if :bkgr > 50 [stop] setbg :bkgr (print [Background color] output first sf) make "penc 1 end to dandelion setheading first shuffle list (random 45) (-1 * (random 45)) make "penstate pen forward 20 + random 80 setpc 1 + random 3 repeat 36 [forward 10 back 10 right 10] penup setpos :root setpen :penstate dandelion end to frame penup setpos [-150 100] pd setx 149 sety -99 setx -150 sety 100 end to demo :list make "success "FALSE catch "error [do.it] if :success = "TRUE [stop] make "error1 error if 52 = first :error1 [do.it] [print first butfirst :error1] end to do.it type "? print :list run :list make "success "TRUE end to do.it1 show run :list make "success "TRUE end to logo.demo print [] print [Here's how Dr. Logo responds to some commands:] print [] demo [make "side 80] demo [repeat 4 [forward :side right 90]] demo [fence] demo [:side] demo [repeat 2 [back :side]] print [] print [That's all, folks!] print [] end to face hideturtle forward 90 make "chin pos setpc 3 repeat 36 [forward 6 left 10] setpc 1 left 90 penup forward 30 left 90 forward 20 setheading 0 eye setheading 90 forward 30 setheading 0 eye setpc 2 setheading 150 forward 10 setheading 180 mouth setpos :chin setheading 0 forward 23 left 5 end to eye pendown repeat 18 [forward 1 right 10] right 100 repeat 8 [forward 1.5 left 6] pu end to mouth pd repeat 18 [forward 2 right 10] right 100 repeat 8 [forward 3 left 6] pu end to pick.a.card output word first shuffle [A K Q J 10 9 8 7 6 5 4 3 2] char first shuffle [3 4 5 6] end to plot.sine make "val 0 make "x -150 make "inc (300 / 60) setx 150 setx :x plot.s :val end to plot.s :val if :x > 150 [stop] make "y (90 * (sin :val)) ; 90 makes plot visible setheading towards list :x :y setpos list :x :y make "x :x + :inc make "val :val + 6 plot.s :val end to measure :xypair1 :xypair2 make "x1 first :xypair1 make "x2 first :xypair2 make "xdif :x2 - :x1 make "y1 last :xypair1 make "y2 last :xypair2 make "ydif :y2 - :y1 make "xdif2 :xdif * :xdif make "ydif2 :ydif * :ydif output sqrt (:xdif2 + :ydif2) end to plot.tan make "val -pi make "inc pi / 37.5 make "x -150 setx 150 setx :x plot.t :val end to plot.t :val if :x > 150 [stop] forward 1000 * tan :val sety 0 setx :x + 4 make "x :x + 4 make "val :val + :inc plot.t :val end to draw.coil print [Enter a bigger number.] forward grow.number right 30 draw.coil end to scale :freq repeat 14 [type list " int 0.5 + :freq tones list 0.5 + :note 300 make "note :note * :c] end to play :song :speed make "note first :song if memberp :note :notes [make interval where] (type " :note) if :note = "R [tones list 0 :speed] [tones list 440 * (:c ^ :interval) :speed] play butfirst :song :speed end to play1 :song :speed make "note first :song if memberp :note :notes [make interval where] (type " :note) if :note = "R [tones list 0 :speed] [tones list 440 * (:c ^ :interval) :speed] if emptyp first butfirst :song [stop] make "note2 first butfirst :song if memberp :note2 :notes [make interval where] (type " :note2) if :note2 = "R [tones list 0 :speed * 4] [tones list 440 * (:c ^ :interval) :speed * 4] play butfirst butfirst :song :speed end to turtle.facts print [] print [Turtle Facts] print [] type [Turtle's X\-coordinate:\ ] print item 1 tf type [Turtle's Y\-coordinate:\ ] print item 2 tf type [Turtle's Heading:\ ] print item 3 tf type [Pen State:\ ] print item 4 tf type [Pen Color:\ ] print item 5 tf type [Turtle Visible:\ ] print item 6 tf print [] end to new.prompt :prompt (type :prompt " ) run readlist new.prompt :prompt end to quiz3 print [Can you play the ocarina?] if "N = uppercase first rq [print [Me neither!]] [print [Wow, I have never met anyone who did!] end to squiral :side repeat 4 [forward :side right 90] right 20 squiral :side + 5 end to make.string :list if emptyp :list [output "] output (word first :list char 32 make.string butfirst :list) end to list.memberp :word :list if emptyp :list [output "FALSE] if wordp first :list [if :word = first :list [output "TRUE] [output list.memberp :word butfirst :list]] if list.memberp :word first :list [output "TRUE] output list.memberp :word butfirst :list end to plaid wrap setpc 3 right 40 forward 10965 setpc 2 right 90 forward 5000 setpc 1 penup right 90 forward 6 pendown ht repeat 625 [forward 3 left 90 forward 1 right 90 back 3 left 90 forward 1 right 90] end to jump setpos list random 150 * first shuffle [1 -1] random 100 * first shuffle [1 -1] end