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

Explanation on passed procedure execution

In SICP lecture 2a, I'm confused on (average (f x) x). Can it not just be (average f x). Doesn't f mean the lambda of (/ x y) already? Why do I need (average (f x) x)? Could someone help me out with the substitution method for this? (define (sqrt…
runners3431
  • 1,425
  • 1
  • 13
  • 30
0
votes
1 answer

sicp counting change exericse

I am working on the counting change algorithm found in the SICP book. I am trying to get it right in Ruby. First, I had trouble with syntax failing now, it has turned into an infinite loop irb(main):001:0> count_change(5) SystemStackError: stack…
honkyblood
  • 13
  • 1
0
votes
2 answers

SICP - Which functions converge to fixed points?

In chapter 1 on fixed points, the book says we can find fixed points of certain functions using f(x) = f(f(x)) = f(f(f(x))) .... What are those functions? It doesn't work for y = 2y when i rewrite it as y = y/2 it works Does y need to get smaller…
vinothkr
  • 1,270
  • 12
  • 23
0
votes
1 answer

How can I solve SICP 2.4 in C++11

This exercise ask for implement cons, car and cdr functions using only lambda functions. The function cons(a,b) create a list of a followed by b, car(l) returns the first element of list l, and cdr(l) returns the rest of the list. I got it working…
Zhen
  • 4,171
  • 5
  • 38
  • 57
0
votes
3 answers

SICP lisp 'if' conditional expression explanation

I'm working through SICP and have gotten to the part about the square root code. I understood that 'if' statements could only be followed by single expressions. However, in the code, (define (sqrt-iter guess x) (if (good-enough? guess x) …
0
votes
2 answers

Unable to evaluate a lambda expression as argument in SICP ex-1.37

The problem can be found at http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-12.html#%_thm_1.37 The problem is to expand a continuing fraction in order to approximate phi. It suggests that your procedure should be able to calculate phi by…
Luke
  • 145
  • 1
  • 10
0
votes
1 answer

SICP Exercise 2.29 Confusion

When I typed my original solution to subproblem b. of exercise 2.29 in SICP: (define (total-weight m) (let ((left (left-branch m)) (right (right-branch m))) (cond ((null? m) 0) ((not (pair? m)) m) (else …
0
votes
1 answer

SICP Exercise 2.19 - how to extend this?

I am just exploring functional programming via SICP, and am wondering how I can extend Exercise 2.19 to do something more useful (and which seems to require side-effects). The exercise involves a program that counts the number of ways one can make…
noobler
  • 3,495
  • 4
  • 22
  • 26
0
votes
2 answers

Scheme if pair end with a space char,the result will have one dot between two element

if pair end with a space char, why result value contains one dot(.)? what does this dot(.) mean? (cons 1 2 ) ;Value 2: (1 . 2) (car (cons 1 2 )) ;Value: 1 (cdr (cons 1 2 )) ;Value: 2 this one seems stupid, because pair only contain two element. …
ray
  • 145
  • 9
0
votes
1 answer

Scheme streams of matrices

I would like to have a stream in scheme that holds a bunch of matrices that have a certain order. The stream-car of this stream would be the matrix [1 6 0 3]; that is, row 1 col 1 is 1, row 1 col 2 is 6, row 2 col 1 is 0, and row 2 col 2 is 3. Each…
Matt
  • 5,408
  • 14
  • 52
  • 79
0
votes
1 answer

SICP Types and Variables

This is from the MIT 6.001 Online Tutor, it's part of the third problem set. Question: Indicate the type of each of the following expressions. If you need type variables, use A,B,C, etc., starting with A as the leftmost variable. (lambda (x y) x) =…
Phea Duch
  • 15
  • 4
0
votes
2 answers

Suggested reading order and other questions

Based on recommendations from episode 57 of the StackOverflow Podcast, I have purchased "Structure and Interpretation of Computer Programs", "The C Programming Language", "Unix Programming Environment", and "Introduction to Algorithms". I'm wanting…
Jacob Winn
  • 495
  • 1
  • 5
  • 10
0
votes
1 answer

Drawing a signal-flow diagram as in SICP

I'm looking for the way to draw such a diagram as http://mitpress.mit.edu/sicp/full-text/book/ch3-Z-G-35.gif, http://mitpress.mit.edu/sicp/full-text/book/ch3-Z-G-49.gif, http://mitpress.mit.edu/sicp/full-text/book/ch3-Z-G-51.gif, named after…
Yai0Phah
  • 433
  • 4
  • 14
-1
votes
1 answer

Regex to extract S expression?

I'm wondering if it's possible to do a pass on parsing of a define expression in lisp with a single regular expression, for example with the following input: #lang sicp (define (square x) (* x x)) (define (average x y) (/ (+ x y) 2)) ; using block…
samuelbrody1249
  • 4,379
  • 1
  • 15
  • 58
-1
votes
1 answer

Why does this arithmetic code return lists?

I'm currently working my way through exercise 3.17 of SICP. I know that I'm messing it up and I intend to fix that later. I will not link the exercise, as it is not relevant. This was one of my attempts: #lang sicp (define (count-pairs x) (define…
J. Mini
  • 1,868
  • 1
  • 9
  • 38
1 2 3
43
44