New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs

# Tag Info

## Hot answers tagged sicp

Accepted

### SICP 1.3 Sum of Squares of two largest numbers

In my opinion this is too much code for such a simple task. Assuming that you do not have a max function, you can define it in this way: ...
• 2,055
Accepted

### Pascal's triangle in mit-scheme

Keep your concerns separated One design principle that is vital to engineering good software is that of "separation of concerns". In other words, each function should be concerned with doing one, ...
• 895

### Iterative "counting change" implementation in mit-scheme

In SICP the authors note: Count-change generates a tree-recursive process with redundancies similar to those in our first implementation of fib. (It will take quite a while for that 292 to be ...
• 41
Accepted

### SICP - exercise 1.7 better end test for square root approximation

sqrt-iter You compute (improve guess x) twice - this is a waste. You return guess instead ...
• 1,405
Accepted

### SICP exercise 1.28 - miller-rabin primality test

To ensure I understood the SICP exercise correctly, I wrote my own version of the Miller-Rabin algorithm. You can look at my code and compare against yours. With this in mind, here's my correctness-...
• 2,342
Accepted

### Church Numerals

Your function + is not correct. The definition of the sum of two Church numerals is the following: ...
• 2,055
Accepted

### SICP - exercise 1.12 - pascal's triangle

You should memoise the recursive call in order to make it faster. Since each value has a computational sibling (its value is derived from (one or two) parents which also each has another child), you ...
• 2,342
Accepted

### SICP - exercise 1.11 - tree recursion

Before looking for efficiency, note that there is a logical error in the tail recursive version of your function: it does not terminate on negative values (while the first function does terminate). ...
• 2,055

### Pascal's triangle in mit-scheme

The sub-definition of pascal-item is what is being asked for in the 1.12 exercise. However it's entirely unsuited for calculating the entire triangle of X rows. ...
• 501

### Generating all unique permutations of a string

Pay attention to your substrings. Given s = "abc", then the following return empty strings. String pre = s.substring(0,0); String post = s.substring(3); Consider ...
• 131

### Iterative "counting change" implementation in mit-scheme

If you add a running sum to the formal parameters of count-iter, you'll have a truly iterative piece of code. As-is, every time through ...
• 501
1 vote

### SICP - exercise 1.7 better end test for square root approximation

With IEEE floating point numbers, the multiplication (* guess 1d-30) may underflow, leading to a 0.0 result. The test would have to be more sophisticated in a real program. Check out these links ...
• 11
1 vote
Accepted

### SICP exercise 1.28 - miller-rabin primality test part II

Stylistically, I'd write it this way: ...
• 1,026
1 vote

### Representing a queue as a procedure with local state

You did not provide implementations of the queue operations using this representation. In SICP this usually refers to syntactic sugar to make working with a data structure less awkward, e.g. ...
• 166

Only top scored, non community-wiki answers of a minimum length are eligible