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

Create an instance from a closure

I am reading the example 3.1Assignment and Local State from SICP #+begin_src scheme (define (make-withdraw balance) (lambda (amount) (if (>= balance amount) (begin (set! balance (- balance amount)) balance) …
AbstProcDo
  • 19,953
  • 19
  • 81
  • 138
0
votes
1 answer

Simulate a bank balance withdraw behavior with lambda

I am reading 3.1 Assignment and Local State of SICP (define balance 100) (define (withdraw amount) (if (>= balance amount) (begin (set! balance (- balance amount)) balance) ; "Insufficient funds")) ;Value: balance 1 ]=>…
AbstProcDo
  • 19,953
  • 19
  • 81
  • 138
0
votes
2 answers

Evaluate combination to tackle recursively (+ 1 2)

I am reading SICP's first chapter 1.1.3 Evaluating Combinations It states that To evaluate a combination, do the following: 1. Evaluate the subexpressions of the combination. 2. Apply the procedure that is the value of the leftmost…
AbstProcDo
  • 19,953
  • 19
  • 81
  • 138
0
votes
1 answer

Can't understand this Tree recursion problem

So i'm going through the SICP book. I'm in the tree recursion chapter. I googled tree recursion to gain more knowledge about it and i stumbled upon this exercice and i'm having hard times to understand it perfectly. Exercice : I want to go up a…
Zakaria Sichaib
  • 87
  • 2
  • 10
0
votes
2 answers

I don't understand how these two variables are proportionate

Structure and Interpretation of Computer Programs section 1.2.1 Linear Recursion and Iteration: Compare the two processes... each requires a number of steps proportional to n to compute n! The two processes are specified by (define (factorial n) …
mohamadc
  • 13
  • 1
0
votes
0 answers

Square Roots by Newton's Method (SCIP example 1.1.7) in R code

I want to apply Newton's Method for square root through iterations in RStudio, but I keep getting error "Error: C stack usage 7969204 is too close to the limit" when I put a wrong sqrt in the 'g'. Instead, the code works fine when I write…
0
votes
1 answer

The Newton Square Root Approximation - But It Won't Return The Value?

So I'm trying to follow along with the SICP lectures in Python, and have constructed the simple blackbox model for a Newtonian method of finding the square root approximations. The code itself seems to work fine, but my function keeps returning a…
Anoni Moose
  • 35
  • 1
  • 4
0
votes
1 answer

Trying to write hyper-operations in scheme

I am trying to write a hyperoperation program in MIT/GNU-Scheme however am having some trouble, I have written individual ones up to n=5 working but would like to make one that functions does them all. I will include some of my failed attempts…
sklss
  • 3
  • 1
0
votes
0 answers

C-m-% keybindings for navigating parenthesis in emacs in iTerm2 on OSX

Im using Emacs 26.1 on my OSX Mojave machine. I run emacs in iTerm2 terminal. Control key was working fine but I had to map the left option key and right option key to Esc+, to get the Meta key to work. Im writing scheme code in emacs and i want to…
raza.sayed
  • 539
  • 1
  • 9
  • 23
0
votes
1 answer

how to handle this error generated in doing sicp exercise 4.9?

I am doing the exercise.4.9 of the sicp and I am trying to implement a syntax of the "for statement" which looks like the others would see in the c++: (for (((i 0) (j 1)) (< (+ i j) 10) ((i (+ i 1)))) (display "i:") (display…
Liu Weibo
  • 434
  • 5
  • 16
0
votes
1 answer

What's the different between '(a b (c)) and (list 'a 'b (list 'c))

I am working on exercise 2.57 and I have such a problem what's the different between '(a b (c)) and (list 'a 'b (list 'c)) since they look exactly the same in the scheme interpreter? 1 ]=> (eq? '(a b (c)) (list 'a 'b (list 'c))) ;Value: #f 1 ]=>…
Liu Weibo
  • 434
  • 5
  • 16
0
votes
1 answer

Scientific notation in Scheme

I am working on the exercises of SICP. In Ex1.22 I've got a question on the performance of scientific notation in Scheme. This exercise is to find a specified count of prime numbers larger than a specified value. ; code to check whether a number…
Orpheus
  • 127
  • 1
  • 8
0
votes
1 answer

contract violation expected: number? given: # argument position: 2nd other arguments...: 1535481725945

Try to check imput number to even in this code: (define (square n) (* n n)) (define (smallest-divisor n) (find-divisor n 2)) (define (find-divisor n test-divisor) (cond ((> (square test-divisor) n) n) ((divides? test-divisor n)…
0
votes
1 answer

SICP Ex 1.3 error ;Syntactic keyword may not be used as an expression: #[keyword-value-item 13]

Hey I am trying to write some scheme can you help me out here? (define (square a b) (+ (* a a) (* b b))) (define (sumsq x y z) (cond (and (< x y) (< x z) (square y z)) (and (< y x) (< y z) (square x z)) (else (square y…
shinigaami25
  • 117
  • 1
  • 7
0
votes
1 answer

MIT Scheme Int VS Float

I've been working through SICP using mit-scheme to test the exercises. For Exercise 1.8 you are tasked to write a cube-root function analogous to the given square-root function. My solution for that is below; however, I noticed that in the…