Author Topic: [lua] Logo interpreter  (Read 19193 times)

0 Members and 1 Guest are viewing this topic.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: [lua] Logo interpreter
« Reply #15 on: November 09, 2011, 11:53:53 am »
Sure, first i'll expand it (short function names to long function names):
Code: [Select]
;define subroutine sierp
to sierp :n :l
    ;if the level is zero, stop
    if :n=0 [stop]

    ;Draw 3 lines for the triangle, while calling itself recursively (to draw the triangles on the sides)
    repeat 3 [
        sierp :n-1 :l/2
        forward :l
        right 120
    ]
end

;put the turtle on the right spot
penup
back 100
left 90
back 100
pendown

;Draw a sierpinski triangle, 5 levels deep (200 is the size)
sierp 5 200

That should be clear enough :)
« Last Edit: November 09, 2011, 11:55:01 am by jimbauwens »