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
671
questions
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 ...
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:
...
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 ...
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 ...
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 ...
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 ...
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)
(...
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 (...
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):
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...