Bob Gorman <bgorman@kncell.org> writes:
>to b.sum :a :b
>if :debug [show (LIST ">b.sum :a :b)]
>output b.add :a :b 0
>if :debug [show (LIST "<b.sum :a :b)]
>end
>
>I made the same modification to each routine, with the same result, entrance
>works, but exit doesn't.
OUTPUT in Logo terminates the procedure it's in. Once the procedure
has output a result, it's finished! Try this:
to b.sum :a :b
if :debug [show (LIST ">b.sum :a :b)]
localmake "result b.add :a :b 0
if :debug [show (LIST "<b.sum :a :b "==> :result)]
output :result
end
(If you're not using UCBLogo or MSWLogo, just say MAKE instead of
LOCALMAKE.)
Footnote: The cost of this is that the call to b.add is no longer
a tail call, so more space is needed for temporary storage of local
variables. But if you don't run out of memory, that's unimportant.
Footnote 2: If you *are* using UCBLogo or MSWLogo, then instead of
all this effort you can just say
trace "b.sum
and Logo will print these messages on its own.
---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org. Mail
questions about the list administration to logofdn@gsn.org. To
unsubscribe send unsubscribe logo-l to majordomo@gsn.org.
Global SchoolNet Foundation -
Linking Kids Around the World!
Copyright GSN - All Rights Reserved
- Comments
& Questions
Visit GSN's
Global
Schoolhouse for more exciting learning resources!
Search our Site
-
Home