Ask your own question, for FREE!
MIT 6.001 Structure and Interpretation of Computer Programs, Spring 2005 51 Online
OpenStudy (anonymous):

In Exercise 1.4 of SICP, not clear what it's asking for. Is it to illustrate that a-plus-abs-b is a compound expression that can be used in other combinations?

OpenStudy (anonymous):

This is actually a very neat capability of Scheme (and other Lisps) not found in most other languages. Scheme expressions have the form: (operator arg1 arg2 ...), and to evaluate this, the interpreter evaluates the operand (giving a procedure) and all the arguments, and then applies the procedure to the arguments. In the given code: (define (a-plus-abs-b a b) ((if (> b 0) + -) a b)) if you stare at the expression ((if (> b 0) + -) a b), you will recognize that the operator is a compound expression: (if (> b 0) + -). After the interpreter evaluates this, it returns either + or -, which are primitive procedures. So, the previous form ((if (> b 0) + -) a b) changes to either (+ a b) or (- a b), depending on the value of b that you give by calling (a-plus-abs-b a b). This brings nice runtime dynamism to procedure application.

OpenStudy (anonymous):

Good explanation -- indeed, this is a very interesting aspect.

OpenStudy (anonymous):

Thanks, I spotted an error in my explanation: should be "...the interpreter evaluates the operator (giving a procedure)...", not "operand".

OpenStudy (anonymous):

I won't be much help with this stuff I'm not into low level machine langauges :) If i run across anything that helps I'll revisit this thread. :)

OpenStudy (anonymous):

How wonderful the answer is!It is really a good way to expand our vison.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!