1 of 24

SICP Study Session 1

Elements of Programming

2 of 24

What is Computer Science?

3 of 24

4 of 24

5 of 24

6 of 24

Procedures Vs Processes

7 of 24

Procedure

Process

8 of 24

Elements in Programming

Procedures

Data

9 of 24

“The language also serves as a framework within which we organize our ideas about processes.”

10 of 24

Three mechanisms to organize ideas

11 of 24

What are expressions?

Anything (or a construct) that returns a value upon evaluation.

12 of 24

Combinations

(+ 100 200)

300

{

Operator

Operands

13 of 24

The value of a combination is obtained by applying the procedure specified by the operator to the arguments that are the values of the operands.

14 of 24

Creating Abstractions

(define pi 3.14)

variable

value

15 of 24

Define is the simplest means of abstraction is Scheme (a dialect of LISP). It is a variable-binding construct.

16 of 24

How LISP interpreter evaluates an expression?

To evaluate a combination, do the following:

1. Evaluate the subexpressions of the combination.

2. Apply the procedure that is the value of the leftmost subexpression (the operator) to the arguments that are the values of the other subexpressions (the operands).

17 of 24

How is the interpreter going to evaluate this?

18 of 24

Tree Accumulation

19 of 24

Defining a procedure

20 of 24

Compound Procedure

21 of 24

The Substitution Model for Procedure Application

Applicative Order

(default)

Normal Order

Types of Evaluation

22 of 24

(define (square x) (* x x))

(define (sum-of-squares x y)

(+ (square x) (square y)))

(define (f a)

(sum-of-squares (+ a 1) (* a 2)))

23 of 24

(define (p) (p))

(define (test x y)

(if (= x 0)

0

y))

(test 0 (p))

24 of 24

Thank You