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

Why can't I use 'and' as the predicate in my 'cond' expression?

I am a self-taught software engineer who is trying to fill in their CS knowledge gaps by following the SICP book which comes highly recommended. I'm having trouble with one of the first exercises and I'm pretty sure it's a syntax problem, but I…
Elliott Rhys
  • 289
  • 1
  • 2
  • 16
-1
votes
2 answers

SICP Exercise 1.11

I can't get the results of the execution. I think it's repeated indefinitely. I made a structure by adding 1 to the count and repeating it. What did I do wrong? #lang sicp (define (fi n) (f-iter 0 3 n)) (define (f-iter sum count n) …
acho
  • 53
  • 7
-1
votes
1 answer

Scheme recursion with dotted-tail notation

I am trying to do exercise 2.20 from SICP. It has introduced the dotted-tail notation. Before I can finish the exercise I need help understanding what is wrong with this test program I have written: (define (f . b) (if (null? b) '() (cons (car…
user1488
  • 131
  • 4
-1
votes
1 answer

Interpreting SCHEME for SICP

I have read through a bunch of Structures and Interpretations of Computer Programs and it has really captured me. I love they way it explains programming concepts. But the problem is that I don't know how to get MIT Scheme working. I don't know much…
SepZ
  • 11
  • 6
-1
votes
1 answer

SICP ex 1.10. Shouldn't we solve it like this:-

I was just solving the book Structure and Interpretation of Computer Programs and have a question concerning exercise 1.10, which, using Ackermann's function defined as (define (A x y) (cond ((= y 0) 0) ((= x 0) (* 2 y)) ((= y 1) 2) …
-1
votes
1 answer

Error: (/) bad argument type: # Chicken Scheme Square root approximation

I am following the SICP lectures from MIT, and this is what I tried to find the square root approximation of a number by Heron of Alexandria's method. This is my first time trying out lisp, sorry for making noobie mistakes. (define guess 1) (define…
twodee
  • 606
  • 5
  • 24
-1
votes
1 answer

SICP example. cond works but if doesn't

If I use the following code from chapter 1 of SICP it gives the correct answer. (cond ((= a 4) 6) ((= b 4) (+ 6 7 a)) (else 25)) prints 16 If I replace the cond by an if it doesn't work (if ((= a 4)6) ((= b 4) (+ 6 7 a)) (else 25)) gives error:…
darthcoder
  • 109
  • 3
-1
votes
1 answer

Scheme function won't print

Please tell me why the following Scheme function won't print the result. I'm using DrRacket. #lang sicp (define (sqr x) (* x x)) (define (sum_of_greatest_squares a b c) (if(> a b) (if(> a c) (if(> b c) ((+…
spheroid
  • 154
  • 1
  • 4
  • 14
-1
votes
5 answers

How do I type the code to the exercises in SICP?

I have been using the print eval loop, but should I be using something else?
Ethan Watson
  • 177
  • 1
  • 1
  • 8
-1
votes
1 answer

Deconstructing a recursive process - SICP

Consider the following definition: (define foo (lambda (x y) (if (= x y) 0 (+ x (foo (+ x 1) y))))) What is the test expression? (write the actual expression, not its value) I would think it is just (if (= x…
-1
votes
2 answers

SICP 2.42 eight queens. Help check what's wrong with my code?

The program is to generate all possible results of eight queens. I use a list which cotains row numbers as the data structure. But when I run it, I got wrong results. Here is my Code: (define (queens board-size) (define (safe? k position) …
Ray
  • 1
  • 1
-2
votes
1 answer

Is num a bound variable or a free variable?

def function() num = 1 num += 1 return num Is num a bound variable or a free variable? P.S. This code is written in python. There's no former code ahead of this.
-3
votes
1 answer

which Lisp dialect should I use and *how* should I get started for SICP? I use Dr. Racket & know a little Racket

I've been working with Dr. Racket (just started) for the "Programming Languages" MOOC on Coursera through University of Washington. So I'm just starting to learn the Racket language. In tandem with that I'd like to start reading SICP and watching…
E.J.
  • 61
  • 2
  • 7
-3
votes
2 answers

SICP terminology : difference between procedure and operation

Is the term "procedure" synonymous with the term "operation" in SICP or not? (For example in the chapter below.) If they are not the same, what is the difference and why? More specifically, what is the difference between "compound operation" and…
jhegedus
  • 20,244
  • 16
  • 99
  • 167
-3
votes
2 answers

Scheme tree map

Write n analogous function (maptree f t) that returns a tree made by applying the function f to each entry of the binary tree t. (Just like map) Since the tree is a data abstraction, only the followings are allowed to operate on trees:(entry t)…
user2272867
1 2 3
43
44