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
0
votes
1 answer

How is a primitive procedure tagged in SICP's evaluator (chapter 4)?

I am reading chapter 4 of SICP. In the eval procedure, there is a procedure application. This procedure checks whether the expression is tagged with the symbol 'primitive or 'procedure. I can see where the symbol 'procedure is added. (It is when…
Gradient
  • 2,253
  • 6
  • 25
  • 36
0
votes
1 answer

vim syntax highlighting for multiline comments in MIT Scheme

I'm working on SICP exercises and using vim to edit MIT Scheme source codes, but it seems the syntax highlighting feature for multiline comments does not work properly. It seems the lines between #| and |# are not recognized as comments. Here's a…
0
votes
1 answer

Exercise 1.3 SICP Error: Cannot evaluate expression in Racket

I am doing Exercise 1.3 from SICP. My code is the following: #lang racket (require sicp) (define (square a) (* a a) ) (define (sum-of-squares a b) (+ (square a) (square b) ) ) (define (max a b) (cond ((>= a…
Tanveer Salim
  • 27
  • 1
  • 1
  • 9
0
votes
2 answers

What does "next" mean in this context?

I'm reading SICP and using Dr Racket SICP package as IDE and interpreter. Code from SICP: (define (sum func a next b) (if (> a b) 0 (+ (func a) (sum func (next a) next b)))) (define (inc n) (+ n 1)) (define (sum-cubes a b) …
Nicholas Humphrey
  • 1,220
  • 1
  • 16
  • 33
0
votes
1 answer

SICP 1.2.4 typo in fast-exp?

I am going through SICP and I am not sure if this is a mistake in the book or maybe I missed something. For calculating fast-exp authors gave the following rules: b^n = (b^(b/2))^2 if n is even b^n = b * b^(n - 1) if n is odd However when they…
dptd
  • 274
  • 1
  • 3
  • 12
0
votes
1 answer

Dr.Racket for SICP

I am setting up DR.Racket for SICP. By following this guide http://docs.racket-lang.org/sicp-manual /index.html?q=sicp#%28part._.Introduction_to_the__lang_sicp_language%29 But I am not able to download sicp package. Following is the error message I…
0
votes
1 answer

Understanding of the part of the code

Please, can you explain to me what the part of if (the one that is noted with ***) is doing? The explanation given was that it adds conditional to the (term a). However, I think in that case there must be written something like: (if (filter term…
user13
  • 351
  • 3
  • 17
0
votes
2 answers

sicp 1.44 why it is a #

#lang planet neil/sicp (define dx 0.00001) (define (smooth-n f n) (repeat smooth f n)) (define (smooth f) (lambda (x) (/ (+ (f x) (f (- x dx)) (f (+ x dx))) 3))) (define (compose f g) (lambda (x) (f (g x)))) (define (repeat f g n) …
0
votes
1 answer

SICP exercise 4.5

I'm learning SICP and do the programming exercises. I have a question about exercise 4.5. The exercise 4.5 is: Scheme allows an additional syntax for cond clauses, ( => ). If evaluates to a true value, then is…
0
votes
1 answer

SICP Help me understand this

The following program finds the smallest integral divisor (greater than 1) of a given number n. It does this in a straightforward way, by testing n for divisibility by successive integers starting with 2. (define (smallest-divisor n) (find-divisor…
Martin
  • 9
  • 1
0
votes
1 answer

about racket remainder expected params

recently, i'm learning sicp but I meet a strange question : Error: remainder: contract violation expected: integer? given: '(3 4 5 6) argument position: 1st other arguments...: 2 here's my code (define (same-parity sample . other) …
Ceuvres
  • 13
  • 4
0
votes
1 answer

scheme - print is undefined in this code

The problem i am having is that i have been given this code to test and use to analyse. Except when i run it, the print definition is being complained about. It keeps saying "print: undefined" Can anyone supply me with a print definition which will…
Swallows
  • 199
  • 1
  • 1
  • 11
0
votes
1 answer

scheme, sicp, solution 3.19, procedure with infinite loop works in case it is provided as argument

could someone help me with clarification to one of the possible solution to exercise 3.19. the procedure mystery is infinite loop in case list cycle is given as argument. nevertheless when we use procedure eq? to check if list contains the cycle, it…
Oliver
  • 79
  • 1
  • 8
0
votes
1 answer

Using element-of-set?

Currently trying to wrap my head around data abstraction for binary trees in Scheme. I am following the SICP-curriculum, and looking at an implementation for a binary tree, but I am unsure of how to use it. ;; Abstraction barrier (define…
0
votes
2 answers

Implementing Scheme's if clause using only cond

Question: Consider a metacircular evaluator which does not implement the if construct, but only a cond. Louis Reasoner claims that if is unnecessary, since we could evaluate the following procedure using the metacircular evaluator: (define (if…
yzhan
  • 170
  • 1
  • 3
  • 13