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
2 answers

Scheme/Racket - Undefined Function; Cannot use before initialization

Currently going through SICP, and near the end of the first chapter, they ask you to program a value for pi, with pi/4 = (2 * 4 * 4 * 6 * 6 * 8 * ...) / (3 * 3 * 5 * 5 * 7 * 7 *..) I have the following functions defined: ;Term and Next are both…
Ricardo Iglesias
  • 595
  • 2
  • 6
  • 16
0
votes
1 answer

SICP ex 3.17 - Counting Pairs - I can't see why my answer goes wrong

Can someone explain why the below doesn't work? I'm going through SICP. This exercise wants you to make a function that counts the pairs of a structure. The program is used on three structures, all with three pairs. (define (count-pairs x) (define…
user12858
  • 3
  • 1
0
votes
1 answer

count change SICP

I was reading the SICP and encountered with a problem, in chapter 1 there is an example named counting change, I need to write a program in scheme to calculate the possible number of ways to make a change of any given number given half-dollars,…
0
votes
1 answer

Understanding block structure in MIT Scheme

Take the following function definition as my example: (define (foo) (bar) (define (bar) (display "bar"))) This would produce an error: ;Premature reference to reserved name: bar. On the contrary, the following two definitions are…
nalzok
  • 14,965
  • 21
  • 72
  • 139
0
votes
4 answers

Building map with Racket

I was building the map function as a matter of practice. I came up with the following code: #lang racket (define (map procedure items) (if (null? items) empty (cons (procedure (car items)) (map procedure (cdr items))))) I tried this…
user4206400
0
votes
2 answers

Building the filter built-in function with Racket

I am trying to build filter (a built-in function) using Racket just as a matter of practice. I created the following code: (define (filter lista-1 check-function) (define (fil-iter lista-1 check-function lista-2) (cond ((null? lista-1) lista-2) …
user4206400
0
votes
2 answers

procedures vs. built-in data

I'm trying to understand the view that procedures and data are virtually the same in lisp. SICP says that: the values of numerals are the numbers that they name, the values of built-in operators are the machine instruction sequences that carry out…
lightning_missile
  • 2,821
  • 5
  • 30
  • 58
0
votes
1 answer

How to debugg iterative procedures?

I am using Dr. Racket and Racket for educational purposes (studying the SICP book). Dr. Racket is great and it has an awesome tool called "trace". After using: (require trace/racket) (trace function) It is possible to see what is happening in a…
user4206400
0
votes
1 answer

Should lazy evaluation of set! be in fact strict?

The SICP book describes how to implement a Scheme interpreter in Scheme. I have been playing with this on and off for months now and my code has evolved away from the book. I have now reached the stage where having implemented a strict-eval…
Sven Williamson
  • 1,094
  • 1
  • 10
  • 19
0
votes
1 answer

SICP - Lambda output

I defined the following procedure using Racket and inside the IDE Dr. Racket: (define (random a b c x) (lambda (a b c x) (+ (* a (* x x)) (* b x) c))) As you might see, there is a lambda expression inside it. I tried…
user4206400
0
votes
1 answer

SICP - Recursive or iterative process?

I am using the SICP book and I am struggling with the concepts of recursive versus iterative process. At the question 1.17 they ask this: Exercise 1.17. The exponentiation algorithms in this section are based on performing exponentiation by means…
user4206400
0
votes
2 answers

lambda calculus - if more parameters needed

Lambda Calculus Question: TRUE = lambda x y . x FALSE = lambda x y . y 1 = lambda s z . s z 2 = lambda s z . s (s z) ... BoolAnd = lambda x y . x y FALSE BoolOr = lambda x y. x TRUE y BoolNot = lambda x . x FALSE TRUE If I want to know the result…
Andy
  • 13
  • 4
0
votes
1 answer

SICP - Code improvement with more abstraction

I am using the SICP book and I did this exercise: 1.11 A function f is defined by the rule that f(n) = n if n<3 and f(n) = f(n - 1) + 2f(n - 2) + 3f(n - 3) if n> 3. Write a procedure that computes f by means of a recursive process. Write a procedure…
user4206400
0
votes
1 answer

Need to Specifically Learn Scheme Knowing Java and Python

I would like to read SICP but I don't want to fully learn Scheme. I know Java, C#, and Python all very well, so would it be possible to pick up Scheme quickly while still getting the full value out of the book?
Dylan Siegler
  • 742
  • 8
  • 23
0
votes
1 answer

What is the alternative to Tagged Data of scheme in C++

I have been trying to solve this problem in SICP. The link also has a solution. Link to the problem's underlying concept in SICP Here is the problem description. Insatiable Enterprises, Inc., is a highly decentralized conglomerate company…
Tarun Maganti
  • 3,076
  • 2
  • 35
  • 64