Structure And Interpretation Flashcards

1
Q

Can Lisp processes become data?

A

Yes. Lisp descriptions of processes, called procedures, can themselves be represented and manipulated as Lisp data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the ethical definition of formalism?

A

A doctrine stating that acts are right or wrong of themselves regardless of consequences.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the mathematical definition of formalism?

A

A doctrine that mathematics, including the logic used in proofs, can be based on the formal manipulation of symbols without regard to their meaning.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In what year was Lisp invented?

A

1958

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What active language is older than Lisp?

A

Fortran, specified in 1957

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Who conceived of Lisp?

A

John McCarthy in his paper “Recursive Functions of Symbolic Expressions and Their Computation by Machine.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a Lisp interpreter?

A

It is a machine that carries out processes described in the Lisp language.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

A powerful programming language is a means for instructing a computer to perform tasks, and what else?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Describe the three ways in which powerful computer languages turn simple ideas into complex ideas.

A
  1. Primitive expressions, which represent the simplest entities the language is concerned with. 2. means of combination, by which compound elements are built from simpler ones, and 3. means of abstraction, by which compound elements can be named and manipulated as units.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the two elements with which programming deals?

A

Procedures

Data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Define Evaluate

A

To find the value of

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

One kind of primitive expression you might type is a number. What, precisely, is happening when you type a number?

A

More precisely, the expression that you type consists of the numerals that represent the number in base 10.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

(+ 3 4)

Describe what, precisely, this is?

A

Expressions representing numbers may be combined with an expression representing a primitive procedure (such as + or *) to form a compound expression that represents the application of the procedure to those numbers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do expressions become combinations?

A

Combinations are formed by delimiting a list of expressions within parentheses in order to denote procedure application.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How is a combination evaluated?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Define Delimit

A

To officially set or state the limits of something.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the difference between a parameter and an argument?

A

The term parameter (sometimes called formal parameter) is often used to refer to the variable as found in the function definition, while argument (sometimes called actual parameter) refers to the actual value passed.

18
Q

What is one good reason for prefix notation?

A

Prefix notation has several advantages. One of them is that it can accommodate procedures that may take an arbitrary number of arguments:
(+ 32 33 33 32 23 233 233 3322 323 … n)

19
Q

Define “pretty printing” as it pertains to Lisp

A

A convention in which each long combination is written so that the operands are aligned vertically.

20
Q

A critical aspect of a programming language is the means it provides for using names to refer to computational objects. How do we describe this?

A

We say that the name identifies a variable whose value is the object.

21
Q

What is Lisp’s simplest means of abstraction?

A

Define is our language’s simplest means of abstraction, for it allows us to use simple names to refer to the results of compound operations.

22
Q

How are complex programs constructed?

A

Complex programs are constructed by building, step by step, computational objects of increasing complexity.

23
Q

What follows from the possibility of associating values with symbols and later retrieving them?

A

It should be clear that the possibility of associating values with symbols and later retrieving them means that the interpreter must maintain some sort of memory that keeps track of the name-object pairs. This memory is called the environment (more precisely the global environment, since we will see later that a computation may involve a number of different environments).

24
Q

How are primitive cases dealt with when evaluating an expression?

A

We take care of the primitive cases by stipulating that:

the values of numerals are the numbers that they name,

the values of built-in operators are the machine instruction sequences that carry out the corresponding operations, and

the values of other names are the objects associated with those names in the environment.

(The second is a special case of the third, where built-in operators themselves are objects associated with names.)

25
Q

What role does the environment play in a Lisp program?

A

In an interactive language such as Lisp, it is meaningless to speak of the value of an expression such as (+ x 1) without specifying any information about the environment that would provide a meaning for the symbol x (or even for the symbol +).

26
Q

Do the rules for evaluations apply to Lisp definitions?

A

No, (define x 3) is not a combination. Evaluating (define x 3) does not apply define to two arguments, one of which is the value of the symbol x and the other of which is 3, since the purpose of the define is precisely to associate x with a value. The purpose of the define is precisely to associate x with a value.

27
Q

What are exceptions to the general rule for evaluations called?

A

Special Forms

28
Q

What is the general rule for evaluations?

A

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).
29
Q

Is Lisp syntax complicated?

A

In comparison with most other programming languages, Lisp has a very simple syntax; that is, the evaluation rule for expressions can be described by a simple general rule together with specialized rules for a small number of special forms.

30
Q

What is a Lisp procedure definition?

A

A powerful abstraction technique by which a compound operation can be given a name and then referred to as a unit.

31
Q

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

We have here a compound procedure, which has been given the name square. The procedure represents the operation of multiplying something by itself. The thing to be multiplied is given a local name, x, which plays the same role that a pronoun plays in natural language. Evaluating the definition creates this compound procedure and associates it with the name square.

A

Observe that there are two different operations being combined here: we are creating the procedure, and we are giving it the name square. It is possible, indeed important, to be able to separate these two notions – to create procedures without naming them, and to give names to procedures that have already been created.

32
Q

What is the difference between applicative-order evaluation and normal-order evaluation?

A

In applicative-order evaluation, the interpreter first evaluates the operator and operands and then applies the resulting procedure to the resulting arguments.

Normal-order evaluation would not evaluate the operands until their values were needed. Instead it would first substitute operand expressions for parameters until it obtained an expression involving only primitive operators, and would then perform the evaluation.

33
Q

What is the special form for case analysis in Lisp?

A

Cond

34
Q

Describe the general form of “cond”

A

The symbol cond is followed by parenthesized pairs of expressions called clauses. The first expression in each pair is a predicate – that is, an expression whose value is interpreted as either true or false.

35
Q

How are case analysis with “cond” evaluated?

A

The predicates are evaluated one at a time to see whether they are true or false. This process continues until a predicate is found whose value is true, in which case the interpreter returns the value of the corresponding consequent expression of the clause as the value of the conditional expression. If none of the predicates are found to be true, the value of the cond is undefined.

36
Q

Define predicate

A

The word predicate is used for procedures that return true or false, as well as for expressions that evaluate to true or false.

37
Q

Define Else

A

Else is a special symbol that can be used in place of the a predicate in the final clause of a cond. This causes the cond to return as its value the value of the corresponding whenever all previous clauses have been bypassed. In fact, any expression that always evaluates to a true value could be used as the predicate here.

38
Q

Define the special form “if”

A

A restricted type of conditional that can be used when there are precisely two cases in the case analysis.

39
Q

How is an if expression evaluated?

A

To evaluate an if expression, the interpreter starts by evaluating the part of the expression. If the evaluates to a true value, the interpreter then evaluates the and returns its value. Otherwise it evaluates the and returns its value.

40
Q

Which of the three logical operators “and”, “or” and “not” are special forms?

A

“And” and “or” are special forms, not procedures, because the subexpressions are not necessarily all evaluated. Not is an ordinary procedure.