Skip to main content

Questions tagged [sicp]

SICP is the book Structure and Interpretation of Computer Programs by Harold Abelson and Gerald Jay Sussman with Julie Sussman and published by the MIT Press.

sicp
0 votes
1 answer
26 views

How to make `set!` change the variable in `let` (Scheme)?

Recently when I self-learnt MIT 6.5151 course, I have read SICP 1 to 2.1 as ps0 requires (also read 2.2.1 as CS 61A notes requires) and then Software Design for Flexibility (SDF) Prologue, chapter 1 ...
An5Drama's user avatar
  • 367
0 votes
1 answer
60 views

Why does Scheme use the procedural representation of pairs?

I am reading SICP. It says in 2.1.3: That is, the operations satisfy the condition that, for any objects x and y, if z is (cons x y) then (car z) is x and (cdr z) is y. ... Here are the definitions: ...
An5Drama's user avatar
  • 367
3 votes
1 answer
51 views

When can we safely use the Randomized algorithm considering probability?

Recently when reading SICP, one footnote says: Numbers that fool the Fermat test are called Carmichael numbers, and little is known about them other than that they are extremely rare. There are 255 ...
An5Drama's user avatar
  • 367
1 vote
1 answer
111 views

`1.0+1e-100=1.` in MIT-scheme

I am reading SICP and read this recitation about chapter 1. I use MIT/GNU Scheme as MIT course 6.5151 (6.905) does with version 12.1. I am stuck at Problem 3. Write a procedure that computes e. I ...
An5Drama's user avatar
  • 367
0 votes
0 answers
54 views

Is there some error-case in this answer? for SICP 1.7

I'm a beginner with SICP. For SICP 1.7, I assume this solution has some problem when '(improve guess x)' keeps returning different values compared to 'guess'. But I can't find an error case for this ...
DongHyun Chae's user avatar
0 votes
2 answers
75 views

Why in SICP one can see seemingly useless evaluation of local variable expressions? Different Scheme implementations behave differently

The deposit and withdraw procedures in the make-account code from SICP both have seemingly useless balance variable expression to evaluate, What is the practical purpose for doing that? (To me it ...
musthero's user avatar
  • 1,288
1 vote
1 answer
130 views

SiCP Exercise 1.45

Update: I changed the argument 1 in nth-root to 1.0, and then it works. Why are they different? Here's my original question. I have (define tolerance 0.00001) (define (fixed-point f first-guess) (...
run an's user avatar
  • 23
1 vote
4 answers
97 views

How to implement "if" in normal order in Scheme?

I was learning SICP and I read about "the applicative order" and "the normal order". Then I played around the Exercise 1-6 and looked into the following code: #lang racket (define (...
Mitchell Xu's user avatar
0 votes
3 answers
66 views

Why is the environment diagram in the following Python code inconsistent with its execution order?

When I was studying the SICP course, the execution order of the following code in the environment diagram is inconsistent with what I expected. def add_one(x): y = x+1 return y def square(x): ...
Quanjiang Liu's user avatar
2 votes
1 answer
142 views

How Can Lisp be defined in terms of y combinator?

I'm watching a lecture SICP 7A and struggling to understand "Define Lisp as Y combinator (time 1:16:15 )" I think I understood that expt ( calculating exponential of a number like x^n ) can ...
codeDog's user avatar
  • 53
1 vote
0 answers
50 views

Eval and Apply in SICP [duplicate]

What is so special about the SICP eval-apply loop? What is so enlightening about it? I understand the process of evaluation, but do not understand what is so universal in it. Programmers also say that ...
Gor's user avatar
  • 13
1 vote
1 answer
56 views

Is an iterative process that returns a list with size that increases by iteration any different from an one that returns a scalar?

This actually comes from me initially misreading the text of Exercise 1.12. The request is indeed to Write a procedure that computes elements of Pascal's triangle by means of a recursive process. I ...
Enlico's user avatar
  • 26.7k
1 vote
2 answers
146 views

Why normal-order and applicative-order evaluation are not giving the same value?

I am reading this book Structure and Interpretation of Computer Programs, 2nd edition and on page 21 under the subsection "Applicative order versus normal order" it is written that - It can ...
Charlie_23's user avatar
0 votes
1 answer
73 views

SICP Environment Diagram with Mermaid.JS

I'm trying to draw an environment diagram, as defined in SICP (see here), programmatically, such that a diagram will be associated with an evaluation of an expression. I'm testing Mermaid.js for that ...
Gino's user avatar
  • 739
1 vote
0 answers
30 views

SICP exercise 5.20

The exercise is from §5.3.1, and the text is copied below: Draw the box-and-pointer representation and the memory-vector representation (as in figure 5.14) of the list structure produced by (define x ...
Enlico's user avatar
  • 26.7k

15 30 50 per page
1
2 3 4 5
45