Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trouble with negative numbers? #3

Open
jywarren opened this issue Aug 24, 2015 · 1 comment
Open

trouble with negative numbers? #3

jywarren opened this issue Aug 24, 2015 · 1 comment

Comments

@jywarren
Copy link
Contributor

I'm not sure I have this right, but I think it this could be choking on negatives (adapted from http://www.logointerpreter.com/view-program.php?user=spaulc90&program=generate_dragon_fractal):

; generates the actual fractal recursively

to dragon_fractal :size :dir
    if :size < 3 [fw :size]
    right 45*:dir
    dragon_fractal :size*(sqrt 2)/2 1
    left 90*:dir
    dragon_fractal :size*(sqrt 2)/2 -1
    right 45*:dir
end

setxy -50 -135

; Initial value 320 gives a nicely centered dragon
; I don't recommend going over 400 or the browser might crash
; (and the dragon will be aout of view)

dragon_fractal 320 1
@jywarren
Copy link
Contributor Author

Ug, I think I solved the negatives issue, but this still won't run due to too much recursion. I'm a little out of my depth, but was reading about tail recursion here; i wonder if there's some optimization such as discussed here that would allow this. Perhaps logointerpreter.com has implemented this.

http://compgroups.net/comp.lang.logo/-logoforum-tail-recursion/325587

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant