
"To differentiate for the top stream it should be possible to teach the concept of parameter substitution so the challenge would be to write a procedure called Polygon which draws one of any number of sides depending on the number passed across. Most class teachers will stop before getting to this stage, which is a shame because for those who 'get it' a whole new world of constructionism opens up.
I have to admit to being one of those class teachers who never got to this stage, so having had a browse around and a bit of a play, here is my first LOGO procedure using parameter substitution routine, is that the right term Andy?!* It is for drawing a polygon of x number of sides as suggested:
To polygon :SIDES
REPEAT :SIDES [FD 100 RT 360/:SIDES]
END
So if I now if I want to draw a hexagon, I can input
polygon 6
The procedure, substitutes sides with the number six, and calculates the turn size, by dividing 360, by the number of sides I want the shape to have.
If I now input
repeat 6 [polygon 6 rt 60]
I can create a pattern like this..

2 comments:
Neat. You've generated a complex optical illusion with just a few characters of code.
Another stage might be to improve on the fixed length of a side.
"polygon 360" should really produce an approximate circle, of similar size to the square "polygon 4" or would it be better to have a second parameter to specify side length?
Simon, great work on this, you gave me a little inspiration to mimic this using Scratch, details here: http://themasterplan.edublogs.org/archives/29
Regards,
Dan
Post a Comment