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

Cannot understand how we can give a procedures as actual parameter when formal parameters are used as values in scheme?

In SICP exercise 1.37 Section 1.3.3 in SICP Scroll Down to the end of section (just before 1.3.4) to find the exercise [3rd exercise in the section]. According to the problem, I defined cont-frac as (define (cont-frac n d k) (if (= k 0) …
Tarun Maganti
  • 3,076
  • 2
  • 35
  • 64
0
votes
1 answer

SICP ex4.12 about share and call-by-value

(define (make-frame var val) (cons var val)) (define (frame-variables frame) (car frame)) (define (frame-values frame) (cdr frame)) (define (add-binding-to-frame! var val frame) (set-car! frame (cons var (car frame))) (set-cdr! frame (cons val…
S.Tian
  • 29
  • 2
0
votes
1 answer

Labels vs instruction sequences in registers (SICP)

In section 5.5.7 of SICP it says External-entry assumes that the machine is started with val containing the location of an instruction sequence that puts a result into val and ends with (goto (reg continue)). Later in the section it says In…
adelbertc
  • 7,270
  • 11
  • 47
  • 70
0
votes
2 answers

almost copied SICP interpreter code in DrRacket, but got error

I'm learning interpreter for quite a long time, after reading SICP chap 4.1~4.2, I tried to copy these code in my DrRacket in planet neil/sicp mode. I've carefully read these code but still cannot made the code running correctly. during my copy, I…
0
votes
1 answer

"not" behavior in Scheme

Why would the Scheme interpreter demand numeric arguments for not? In my case: (not (= 1 2)) returned the following error: -: contract violation expected: number? given: #f context...: stdin::1135: not This is rather contrary to my…
Alex Agapov
  • 125
  • 7
0
votes
1 answer

If the order of growth of a process is `log3 a`, can we simplify it to `log a`?

I'm learning the book SICP, and for the exercise 1.15: Exercise 1.15. The sine of an angle (specified in radians) can be computed by making use of the approximation sin x x if x is sufficiently small, and the trigonometric identity to reduce the…
Freewind
  • 193,756
  • 157
  • 432
  • 708
0
votes
1 answer

How can two things be used after a cond predicate in scheme?

(define (search-for-primes start end) (if (even? start) (search-for-primes (+ start 1) end) (cond ((< start end) (timed-prime-test start) (search-for-primes (+ start 2) end))))) This is part of an answer for…
ABP123
  • 3
  • 1
0
votes
3 answers

Procedures as Arguments in php

I'm learning sicp 1.3(Formulating Abstractions with Higher-Order Procedures).The scheme code can compute the sum of the cubes of the integers from a to b. (define (sum term a next b) (if (> a b) 0 (+ (term a) (sum term (next…
Shadow C
  • 5
  • 2
0
votes
1 answer

An iterative program for appending lists in scheme

I am reading Section 2.2 in SICP where the book introduced the procedure for appending two lists. I am trying to implement the append using iteration. This is my code: (define (append list1 list2) (define (append-iter item1 reversed-item1…
Xiaojun Chen
  • 1,222
  • 2
  • 12
  • 21
0
votes
2 answers

SICP's description of pointers

This quote is from SICP that I think is talking about pointers/references in programming languages. As we have seen, pairs provide a primitive “glue” that we can use to construct compound data objects. Figure 2.2 shows a standard way to visualize a…
lightning_missile
  • 2,821
  • 5
  • 30
  • 58
0
votes
1 answer

Getting rid of outer parentheses on a list

The particular problem I have is with creating a solution for question 4.16b of Structure and Interpretation of Computer Programs. Here a procedure needs to be created that transforms (lambda (a b) (define u 'u) (define v 'v) …
user2609980
  • 10,264
  • 15
  • 74
  • 143
0
votes
1 answer

SICP Exercise 1.17 Aborting!: maximum recursion depth exceeded

I solve it by php,and it works.but I try to use scheme,I receive the " Aborting!: maximum recursion depth exceeded" error. I use MIT/GNU Scheme microcode 15.3 .Here is the code. php function cc($a,$b) { if($b==1){ return $a; …
Shadow C
  • 5
  • 2
0
votes
1 answer

SICP stream exercise: create a stream with alternating values

I was reading SICP chapter 3 and thought of this (consider it a variation of the procedure integers that creates a stream of integers): how do you create a stream of two alternating values? For example you create this: 1 0 1 0 1 0 1 0 ... and you…
0
votes
1 answer

Contradictory assumptions on evaluator in SICP

Exercise 1.6 defines a new-if with cond: (define (new-if predicate then-clause else-clause) (cond (predicate then-clause) (else else-clause))) This new-if would fall into infinite loop when called in a recursion. Example sqrt-iter…
Rahn
  • 4,787
  • 4
  • 31
  • 57
0
votes
1 answer

DrRacket gives the " '(# # #) " output

I am doing ex2.22 of SICP, the exercise gives a procedure which intends to square a list but the output reverses the list. But when I type it in DrRacket the output is unexpected. The code: (define (square-list items) (define (iter things answer) …
Leo
  • 492
  • 1
  • 5
  • 15