sicp.io
1.1.1 · The elements of programming

An expression asks for a value.

Start with combinations. Read the operator first, then the operands, and let evaluation turn the whole form into one value.

Guiding question

What does the evaluator do with a parenthesized combination?

  • Identify the operator and operands in a combination
  • Predict the value before running the program
  • Separate printed output from the returned value

In a combination such as (* 3.14159 (* 5 5)), the first item names the procedure. The remaining items are operand expressions. Lispex evaluates the operands and applies the procedure to their values.

The call to display produces output, but it does not replace the value of the final multiplication. The workbench keeps those two observations separate.

SICP code49 of 1,048,576 UTF-8 bytes
Examples
Result
Output
Value
Diagnostic
Execution trace0 / 0 events
    Programs run in the browser with their result and execution trace.
    Expected result

    The first program prints area and returns 78.53975.

    Trace focus

    Look for the inner multiplication before the outer multiplication. The ordered events expose the nesting that the final number hides.

    Try it yourself

    Change the program and compare the result.

    Change the radius from 5 to 8. Predict the value, then add a second display call without changing the returned area.

    Show hint

    In a begin form, the value of the final expression becomes the value of the whole form.

    Complete this lesson

    0 of 18 lessons complete in this chapter0%