Question

(CO 7) Evaluate the value of the following Scheme expressions. 1. (* 4 5) 2. (+...

(CO 7) Evaluate the value of the following Scheme expressions.

1. (* 4 5)

2. (+ 1 5 3)

3. (+ 2 (- 6 3))

4. ((LAMBDA (x) (* x x x)) 2)

(CO 5) What are the arguments for and against the C++ policy on inlining of methods?

(CO 6) Explain why allowing a class to implement multiple interfaces in Java and C# does not create the same problems that multiple inheritance in C++ creates.

(CO 8) Describe how a multiple-processor machine could be used to implement resolution. Could Prolog, as currently defined, use this method?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer (C07):

1. (* 4 5)

  • This is a procedure call, general form is operator followed by operands.
  • Here operator is *(multiply) and operands are (4 and 5)
  • Output will be 4 multiplied by 5 that is 20.
  • Output: 20

2. (+ 1 5 3)

  • This is a procedure call, general form is operator followed by operands.
  • Here operator is +(add) and operands are (1, 5 and 3)
  • Output will be 1+5+3 that is 9.
  • Output: 9

3. (+ 2 (- 6 3))

  • This is a procedure call, general form is operator followed by operands.
  • Here one procedure is inside another procedure, inner procedure will be evaluated first.
  • For inner procedure (-6 3) output will be 6-3 = 3.
  • For outer procedure (+ 2 3), operator is +(add) and operands are (2 and 3)
  • Output will be 2+3 that is 5.
  • Output: 5

4. ((lambda (x) (* x x x)) 2)

  • This is a lambda expression, that evaluates to a procedure
  • This will evaluate to the procedure (* 2 2 2)
  • Here operator is *(multiply) and operands are (2, 2 and 2)
  • Output will be 2*2*2 that is 8.
  • Output: 8
Add a comment
Know the answer?
Add Answer to:
(CO 7) Evaluate the value of the following Scheme expressions. 1. (* 4 5) 2. (+...
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