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.

Quoting the wikipedia page:

Structure and Interpretation of Computer Programs (SICP) is a textbook published in 1984 about general computer programming concepts from MIT Press written by Massachusetts Institute of Technology (MIT) professors Harold Abelson and Gerald Jay Sussman, with Julie Sussman. It was formerly used as the textbook of MIT introductory programming class and at other schools.

Using a dialect of the Lisp programming language known as Scheme, the book explains core computer science concepts, including abstraction, recursion, interpreters and metalinguistic abstraction, and teaches modular programming.

The book is available online, with accompanying video lectures.

660 questions
7
votes
4 answers

implement parallel execute in scheme

In SICP section 3.4 (serializers in scheme) on Currency there is a procedure called parallel-execute that is described but not implemented in MIT scheme. I wonder if anyone has actually implemented it; if not how would one get started in…
Mark
  • 8,408
  • 15
  • 57
  • 81
7
votes
1 answer

SICP Exercise 1.5

Exercise 1.5. Ben Bitdiddle has invented a test to determine whether the interpreter he is faced with is using applicative-order evaluation or normal-order evaluation. He defines the following two procedures: (define (p) (p)) (define (test x…
JellalF
  • 115
  • 3
7
votes
1 answer

What is the advantage of lexical addressing in Chapter 5 of SICP?

I am reading SICP now and don't really understand the necessity of lexical addressing described in 5.5.6 Lexical addressing of SICP. Since it says "Because our language is lexically scoped, the run-time environment for any expression will have a…
user1461328
  • 742
  • 2
  • 6
  • 13
6
votes
2 answers

implementing foreach (doseq) in clojure

i'm working through SICP - one exercise is to implement foreach (doseq). This is an academic exercise. In clojure, this is what I came up with: (defn for-each [proc, items] (if (empty? items) nil (do (proc (first items)) …
Dustin Getz
  • 21,282
  • 15
  • 82
  • 131
6
votes
2 answers

SICP sqrt NullPointerException

I've encountered an unexpected NullPointerException while implementing some beginning SICP code in Clojure. In particular, I want to implement the iterative square root procedure from section 1.1.7. Here's the code: (defn square [x] (* x x)) (defn…
Alan O'Donnell
  • 1,276
  • 9
  • 17
6
votes
2 answers

SICP Video Lecture 2

I have a problem with this example (define (+ x y) (if (= x 0) y (+ (-1+ x) (1+ y)))) What is the problem with -1+ and 1+, when i evaluate it i get this result DrScheme: -1+: this function is not defined racket : reference to…
Ahmad Ajmi
  • 7,007
  • 3
  • 32
  • 52
6
votes
2 answers

What (define (p) (p)) does?

I'm reading the "Structure and interpretation of computer programs" 2nd edition in the exercise 1.5, I found a combination that I didn't understand what it does exactly (define (p) (p)). When I called the procedure (p) I had the cursor blinking in…
ayman
  • 63
  • 4
6
votes
1 answer

Memoization performance - SICP exercise 3.27 seems to be wrong

Have I uncovered an actual error in the SICP book? It says: Exercise 3.27: Memoization (also called tabulation) is a technique that enables a procedure to record, in a local table, values that have previously been computed. This technique can…
lightning_missile
  • 2,821
  • 5
  • 30
  • 58
6
votes
1 answer

Iterative process vs a recursive process

Reading through SICP Distilled and trying to wrap my head around iterative vs recursive processes. The example given is: (defn + [a b] (if (= a 0) b (inc (+ (dec a) b)))) (defn + [a b] (if (= a 0) b (+ (dec a) (inc b)))) Which of these is an…
diplosaurus
  • 2,538
  • 5
  • 25
  • 53
6
votes
1 answer

Help understanding this implementation of cons and car in scheme using lambdas

My question relates to the following code: (define (cons. x y) (lambda (m) (m x y))) (define (car. z) (z (lambda (p q) p))) My problem is with how this code actually works. As far as I can understand cons. is returning a procedure…
4tlulz
  • 85
  • 3
6
votes
5 answers

Materials for SICP with python?

I want to try out SICP with Python. Can any one point to materials (video.article...) that teaches Structure and Interpretation of Computer Programs in python. Currently learning from SICP videos of Abelson, Sussman, and Sussman.
yesraaj
  • 46,370
  • 69
  • 194
  • 251
6
votes
3 answers

Tail-recursive Pascal triangle in Scheme

I started to read SICP recently, and I'm very interested in converting a recursive procedure into a tail-recursive form. For "one dimensional" situations (linear ones), like the Fibonacci series or factorial computation, it is not hard to do the…
Junjie
  • 469
  • 1
  • 4
  • 14
6
votes
2 answers

Using trace to display a procedure in racket

I've been working through the last few exercises ch 1 of SICP, where several of the exercises uses higher-order functions. Currently I'm trying to debug a problem in my solution to 1.45, which is raising an arity mismatch. The function which is…
LiavK
  • 702
  • 6
  • 20
6
votes
2 answers

SICP: Can or be defined in lisp as a syntactic transformation without gensym?

I am trying to solve the last part of question 4.4 of the Structure and Interpretation of computer programming; the task is to implement or as a syntactic transformation. Only elementary syntactic forms are defined; quote, if, begin, cond, define,…
Edward Ross
  • 215
  • 1
  • 5
6
votes
3 answers

When does scheme evaluate quote?

(car ''abracadabra) is equivalent to (car (quote (quote abracadabra)), and it evaluates to (car (quote abracadabra)) --> quote On the othe hand (car (quote (a b))) evaluates to a, which to me makes sense intuitively. So my question is, why does…
Sebastian Mendez
  • 661
  • 9
  • 18