The message below is being cross-posted from the LogoForum. Please
reply here at comp.lang.logo and it will be cross-posted back to the
LogoForum. The original author of this message is
gene_sullivan@[EMAIL PROTECTED]
In LogoForum@[EMAIL PROTECTED]
John St. Clair <john.stclair@[EMAIL PROTECTED]
>
wrote:
>
> The message below is being cross-posted from comp.lang.logo. Please
> reply to LogoForum@[EMAIL PROTECTED]
or a11 <ashabsurya@[EMAIL PROTECTED]
>.
>
> Hi
>
> I want to draw [ shrink or grow squares ] using recursion in logo
> like stacking them . Can anyone please help me with this?
Maybe. I'll let you decide how helpful this is.
If you define a word `square' with a parameter for side length
it is fairly easy to do as want.
From inside your `square' you can invoke another square
with the parameter fed the argument of the present call,
which has been scaled -- either up or down -- by multiplying
it by a number greater or less than 1, depending on whether
you want larger or smaller squares.
Of course, the important issue is the `stop condition'.
When entering the `square' word you are creating
you will want to test for a stop condition so your
recursive square doesn't recurse indefinitely.
Here is a template
to square :side_length :scaling_factor
;stop condition
if not <too big or small> [
square :side_length * :scaling_factor
]
end
Something like this --^.
As to whether the stop condition is handled as
a constant inside `square', a global variable,
or a parameter is up to you.
Q: what happens if one picks a scaling factor of 1?
Best of luck,
Gene
>
>
> Thanks
>
__._,_.___
LogoForum messages are archived at:
http://groups.yahoo.com/group/LogoForum


|