[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LOGO-L> QUESTION ON CONDITIONAL OUTPUTS



You were real close

TO ADDLISTS :LIST1 :LIST2 :LIST3
IF EMPTYP :LIST1 [OP :LIST3] 
MAKE "A1 FIRST :LIST1 
MAKE "A2 FIRST :LIST2 
MAKE "S :A1 + :A2 
OP ADDLISTS BF :LIST1 BF :LIST2 LPUT :S :LIST3 
END

Remember that you wrote ADDLISTS to output something.
When you call it recursively you have to use it's result.
One reason you got into trouble was your 3rd (:LIST3) argument.
Your thinking that you need a place to put the result.
You don't, the "Output" is where the result will be.

The error message is confusing because it said addlists
did not output in addlists. It's not talking about the call
you made by typing in addlists [1 2] [3 4] [] but it's
talking about the call addlists made to itself.

However, here is a more logical approach.

TO ADDLISTS :LIST1 :LIST2
; We know the answer to empty list thats easy
IF EMPTYP :LIST1 [OP []] 
MAKE "A1 FIRST :LIST1 
MAKE "A2 FIRST :LIST2 
MAKE "S :A1 + :A2 
; We have the answer for one pair (:s) now combine it with the
; the answer for the rest and output it.
OP FPUT :S ADDLISTS BF :LIST1 BF :LIST2
END

The concept is almost like a math induction proof.

PZeidenber wrote:
> 
> IN THE TWO FOLLOWING PROCEDURES:
> 
> TO ADDLISTS :LIST1 :LIST2 :LIST3
> IF EMPTY? :LIST1 [OP :LIST3]
> MAKE "A1 FIRST :LIST1
> MAKE "A2 FIRST :LIST2
> MAKE "S :A1 + :A2
> ADDLISTS BF :LIST1 BF :LIST2 LPUT :S :LIST3
> END
> 
> AND
> 
> TO ?ADDLISTS :LIST1 :LIST2 :LIST3
> IF EMPTY? :LIST1 [PRINT (LIST :LIST3) STOP]
> MAKE "A1 FIRST :LIST1
> MAKE "A2 FIRST :LIST2
> MAKE "S :A1 + :A2
> ?ADDLISTS BF :LIST1 BF :LIST2 LPUT :S :LIST3
> END
> 
> ONLY THE SECOND PRINTS THE ANSWER. THE FIRST OUTPUTS BUT ALSO GIVES AN ERROR
> METHODS AND THE OUTPUT CANNOT BE PASSED TO ANOTHER PROCEDURE. (USING UCB LOGO
> 4.5 OR LOGO PLUS) CAN ANYONE HELP ME WITH THIS PROBLEM?
> 
> PHILLIP ZEIDENBERG PZEIDENBER@AOL.COM
> ---------------------------------------------------------------
> 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.

-- 
===============================================================
George Mills
email: mills@softronix.com
http://www.softronix.com
The www page contains some very powerful educational software.
Our single most important investment is our kids.
---------------------------------------------------------------
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