Question

Four function calculation. Please write this code in Scheme. (Please dont write this code in java,...

Four function calculation.
Please write this code in Scheme. (Please dont write this code in java, c++ or sql. Only in Scheme.) just write the code on Four function calculation.

CODE WILL BE IN SCHEME LENGUAGE.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Sample run:

Scheme code with comments:

(define (ffcalculator expression)
(cond ((null? expression) 0) ; base condition handling zero and one terms
((null? (cdr expression)) (car expression))
(else ; to handle three or more terms
(let ((operand1 (car expression))
(operator (cadr expression))
(operands (cddr expression)))
((case operator ; convert operator and symbol to corresponding function
((*) *)
((/) /)
((+) +)
((-) -))
operand1
(ffcalculator operands)))))) ; evaluate the rest of the expression recursively

Add a comment
Know the answer?
Add Answer to:
Four function calculation. Please write this code in Scheme. (Please dont write this code in java,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT