合集-sicp

摘要:sicp每日一题[1.42]Exercise 1.42 Let f and g be two one-argument functions. The composition f after g is defined to be the function x->f(g(x)). Define a procedure compos 阅读全文
posted @ 2024-09-03 10:27 再思即可 阅读(79) 评论(0) 推荐(0)
摘要:sicp每日一题[1.43]Exercise 1.43 If f is a numerical function and n is a positive integer, then we can form the nth repeated application of f, which is defined to be the 阅读全文
posted @ 2024-09-03 10:55 再思即可 阅读(63) 评论(0) 推荐(0)
摘要:sicp每日一题[1.44]Exercise 1.44 The idea of smoothing a function is an important concept in signal processing. If f is a function and dx is some small number, then the 阅读全文
posted @ 2024-09-04 10:49 再思即可 阅读(26) 评论(0) 推荐(0)
摘要:sicp每日一题[1.45]Exercise 1.45 We saw in Section 1.3.3 that attempting to compute square roots by naively finding a fixed point of y->x/y does not converge, and that t 阅读全文
posted @ 2024-09-05 14:03 再思即可 阅读(272) 评论(0) 推荐(0)
摘要:sicp每日一题[1.46]Exercise 1.46 Several of the numerical methods described in this chapter are instances of an extremely general computational strategy known as iterati 阅读全文
posted @ 2024-09-06 11:50 再思即可 阅读(51) 评论(0) 推荐(0)
摘要:sicp每日一题[2.1]Exercise 2.1 Exercise 2.1: Define a better version of make-rat that handles both positive and negative arguments. make-rat should normalize the sign s 阅读全文
posted @ 2024-09-07 13:43 再思即可 阅读(278) 评论(0) 推荐(0)
摘要:sicp每日一题[2.2]Exercise 2.2 Consider the problem of representing line segments in a plane. Each segment is represented as a pair of points: a starting point and an e 阅读全文
posted @ 2024-09-08 09:01 再思即可 阅读(32) 评论(0) 推荐(0)
摘要:sicp每日一题[2.3]Exercise 2.3 Implement a representation for rectangles in a plane. (Hint: You may want to make use of Exercise 2.2.) In terms of your constructors and 阅读全文
posted @ 2024-09-09 12:20 再思即可 阅读(267) 评论(0) 推荐(0)
摘要:sicp每日一题[2.4]Exercise 2.4 Here is an alternative procedural representation of pairs. Forthisrepresentation, verify that (car (cons x y)) yields x for any objects x 阅读全文
posted @ 2024-09-10 10:42 再思即可 阅读(36) 评论(0) 推荐(0)
摘要:sicp每日一题[2.5]Exercise 2.5 Show that we can represent pairs of nonnegative integers using only numbers and arithmetic operations if we represent the pair a and b as 阅读全文
posted @ 2024-09-11 10:37 再思即可 阅读(30) 评论(0) 推荐(0)
摘要:sicp每日一题[2.6]Exercise2.6 In case representing pairs as procedures wasn't mind-boggling enough, consider that, in a language that can manipulate procedures, we can 阅读全文
posted @ 2024-09-12 11:04 再思即可 阅读(39) 评论(0) 推荐(0)
摘要:sicp每日一题[2.7]2.7 Alyssa’s program is incomplete because she has not specified the implementation of the interval abstraction. Here is a definition of the interval 阅读全文
posted @ 2024-09-13 13:06 再思即可 阅读(28) 评论(0) 推荐(0)
摘要:sicp每日一题[2.8]Exercise 2.8 > Using reasoning analogous to Alyssa's, describe how the difference of two intervals may be computed. Define a corresponding subtraction 阅读全文
posted @ 2024-09-13 13:09 再思即可 阅读(49) 评论(0) 推荐(0)
摘要:sicp每日一题[2.9]Exercise 2.9 The width of an interval is half of the difference between its upper and lower bounds. The width is a measure of the uncertainty of the n 阅读全文
posted @ 2024-09-14 10:54 再思即可 阅读(53) 评论(0) 推荐(0)
摘要:sicp每日一题[2.11]Exercise 2.11 In passing, Ben also cryptically comments: “By testing the signs of the endpoints of the intervals, it is possible to break mul-interval 阅读全文
posted @ 2024-09-15 13:04 再思即可 阅读(28) 评论(0) 推荐(0)
摘要:sicp每日一题[2.10]Exercise 2.10 Ben Bitdiddle, an expert systems programmer, looks over Alyssa’s shoulder and comments that it is not clear what it means to divide by a 阅读全文
posted @ 2024-09-16 23:16 再思即可 阅读(22) 评论(0) 推荐(0)
摘要:sicp每日一题[2.12]Exercise 2.12 Defineaconstructor make-center-percent that takes a center and a percentage tolerance and produces the desired interval. You must also d 阅读全文
posted @ 2024-09-16 23:20 再思即可 阅读(36) 评论(0) 推荐(0)
摘要:sicp每日一题[2.13-2.16]Exercise 2.13 Show that under the assumption of small percentage tolerances there is a simple formula for the approximate percentage tolerance of the 阅读全文
posted @ 2024-09-17 13:20 再思即可 阅读(56) 评论(0) 推荐(0)
摘要:sicp每日一题[2.17]Exercise 2.17 Define a procedure last-pair that returns the list that contains only the last element of a given (nonempty) list: (last-pair (list 23 7 阅读全文
posted @ 2024-09-18 14:02 再思即可 阅读(33) 评论(0) 推荐(0)
摘要:sicp每日一题[2.18]Exercise 2.18 Define a procedure reverse that takes a list as argument and returns a list of the same elements in reverse order: (reverse (list 1 4 9 阅读全文
posted @ 2024-09-19 10:26 再思即可 阅读(36) 评论(0) 推荐(0)
摘要:sicp每日一题[2.19]Exercise 2.19 Consider the change-counting program of Section 1.2.2. It would be nice to be able to easily change the currency used by the program, so 阅读全文
posted @ 2024-09-20 08:03 再思即可 阅读(30) 评论(0) 推荐(0)
摘要:sicp每日一题[2.20]Exercise 2.20 The procedures +, *, and list take arbitrary numbers of arguments. One way to define such procedures is to use define with dotted-tail n 阅读全文
posted @ 2024-09-21 11:40 再思即可 阅读(39) 评论(0) 推荐(0)
摘要:sicp每日一题[2.21]Exercise 2.21 The procedure square-list takes a list of numbers as argument and returns a list of the squares of those numbers. (square-list (list 1 2 阅读全文
posted @ 2024-09-22 08:34 再思即可 阅读(22) 评论(0) 推荐(0)
摘要:sicp每日一题[2.22-2.23]Exercise2.22 Louis Reasoner tries to rewrite the first square-list procedure of Exercise 2.21 so that it evolves an iterative process: (define (square 阅读全文
posted @ 2024-09-23 10:59 再思即可 阅读(27) 评论(0) 推荐(0)
摘要:sicp每日一题[2.24-2.27]2.24-2.26没什么代码量,所以跟 2.27 一起发吧。 Exercise 2.24 Suppose we evaluate the expression (list 1 (list 2 (list 3 4))). Give the result printed by the interpret 阅读全文
posted @ 2024-09-24 10:40 再思即可 阅读(25) 评论(0) 推荐(0)
摘要:sicp每日一题[2.28]Exercise2.28 Write a procedure fringe that takes as argument a tree (represented as a list) and returns a list whose elements are all the leaves of th 阅读全文
posted @ 2024-09-25 11:21 再思即可 阅读(25) 评论(0) 推荐(0)
摘要:sicp每日一题[2.29]Exercise 2.29 A binary mobile consists of two branches, a left branch and a right branch. Each branch is a rod of a certain length, from which hangs e 阅读全文
posted @ 2024-09-26 12:07 再思即可 阅读(30) 评论(0) 推荐(0)
摘要:sicp每日一题[2.30]Exercise 2.30 Define a procedure square-tree analogous to the square-list procedure of Exercise 2.21. That is, square-tree should behave as follows: ( 阅读全文
posted @ 2024-09-27 08:13 再思即可 阅读(26) 评论(0) 推荐(0)
摘要:sicp每日一题[2.31]Exercise 2.31 Abstract your answer to Exercise 2.30 to produce a procedure $tree-map$ with the property that $square-tree$ could be defined as (define 阅读全文
posted @ 2024-09-28 08:37 再思即可 阅读(21) 评论(0) 推荐(0)
摘要:sicp每日一题[2.32]上一道题没什么改动,再来一道 Exercise 2.32 We can represent a set as a list of distinct elements, and we can represent the set of all subsets of the set as a list o 阅读全文
posted @ 2024-09-28 08:40 再思即可 阅读(18) 评论(0) 推荐(0)
摘要:sicp每日一题[2.33]Exercise 2.33 Fill in the missing expressions to complete the following definitions of some basic list-manipulation operations as accumulations: ; p 表 阅读全文
posted @ 2024-09-29 08:27 再思即可 阅读(36) 评论(0) 推荐(0)
摘要:sicp每日一题[2.34]Exercise 2.34 Evaluating a polynomial in x at a given value of x can be formulated as an accumulation. We evaluate the polynomial an x^n + a{n-1} x^(n 阅读全文
posted @ 2024-09-30 17:04 再思即可 阅读(37) 评论(0) 推荐(0)
摘要:sicp每日一题[2.35]十一去喀纳斯玩了2天,今天恢复,才几天没看书再看到代码就感到有点陌生了。。 Exercise 2.35 Redefine count-leaves from Section 2.2.2 as an accumulation: (define (count-leaves t) (accumulate 阅读全文
posted @ 2024-10-06 21:30 再思即可 阅读(26) 评论(0) 推荐(0)
摘要:sicp每日一题[2.36-2.37]果然习惯不能停,就两天没学,昨天就忘的干干净净了。。今天把昨天的补上 Exercise 2.36 The procedure accumulate-n is similar to accumulate except that it takes as its third argument a sequ 阅读全文
posted @ 2024-10-08 11:25 再思即可 阅读(32) 评论(0) 推荐(0)
摘要:sicp每日一题[2.38-2.39]Exercise 2.38 The accumulate procedure is also known as fold-right, because it combines the first element of the sequence with the result of combining 阅读全文
posted @ 2024-10-09 09:01 再思即可 阅读(22) 评论(0) 推荐(0)
摘要:sicp每日一题[2.40]Exercise2.40 Define a procedure unique-pairs that, given an integer n, generates the sequence of pairs (i, j) with 1 < j < i < n. Use unique-pairs to 阅读全文
posted @ 2024-10-10 08:38 再思即可 阅读(34) 评论(0) 推荐(0)
摘要:sicp每日一题[2.41]Exercise 2.41 Write a procedure to find all ordered triples of distinct positive integers i, j, and k less than or equal to a given integer n that sum 阅读全文
posted @ 2024-10-11 08:23 再思即可 阅读(41) 评论(0) 推荐(0)
摘要:sicp每日一题[2.42]这道题太难了,我自己只完成了 empty-board 这一个定义,其他的函数即使看了别人的答案也研究了半天才搞明白。。 ; board-size 指的是正方形棋盘的长 (define (queens board-size) (define (queen-cols k) (if (= k 0) (li 阅读全文
posted @ 2024-10-12 08:20 再思即可 阅读(22) 评论(0) 推荐(0)
摘要:sicp每日一题[2.43]Exercise 2.43 Louis Reasoner is having a terrible time doing Exercise 2.42. His queens procedure seems to work, but it runs extremely slowly. (Louis n 阅读全文
posted @ 2024-10-13 07:56 再思即可 阅读(31) 评论(0) 推荐(0)
摘要:sicp每日一题[2.44]我在这一章遇到了一个大问题,就是书上用的那些函数 beside, wave, flip-vert 我统统用不了。我用的是 DrRacket 这个软件,在网上查了半天,终于找到了解决办法。 首先是官方教程,在 DrRacket 中依次打开 File -> Package Manager...,在弹出的 阅读全文
posted @ 2024-10-14 08:21 再思即可 阅读(33) 评论(0) 推荐(0)
摘要:sicp每日一题[2.45]right-split and up-split can be expressed as instances of a general splitting operation. Define a procedure split with the property that evaluating (d 阅读全文
posted @ 2024-10-15 08:21 再思即可 阅读(32) 评论(0) 推荐(0)
摘要:sicp每日一题[2.46]Exercise 2.46 A two-dimensional vector v running from the origin to a point can be represented as a pair consisting of an x-coordinate and a y-coordin 阅读全文
posted @ 2024-10-16 08:35 再思即可 阅读(36) 评论(0) 推荐(0)
摘要:sicp每日一题[2.47]Exercise 2.47 Here are two possible constructors for frames: (define (make-frame origin edge1 edge2) (list origin edge1 edge2)) (define (make-frame or 阅读全文
posted @ 2024-10-17 08:40 再思即可 阅读(25) 评论(0) 推荐(0)
摘要:sicp每日一题[2.48]Exercise 2.48 A directed line segment in the plane can be represented as a pair of vectors—the vector running from the origin to the start-point of th 阅读全文
posted @ 2024-10-18 08:53 再思即可 阅读(25) 评论(0) 推荐(0)
摘要:sicp每日一题[2.49]Exercise 2.49 Use segments->painter to define the following primitive painters: a. The painter that draws the outline of the designated frame. b. The 阅读全文
posted @ 2024-10-19 12:45 再思即可 阅读(41) 评论(0) 推荐(0)
摘要:sicp每日一题[2.50]Exercise 2.50 Define the transformation flip-horiz, which flips painters horizontally, and transformations that rotate painters counterclockwise by 18 阅读全文
posted @ 2024-10-20 09:12 再思即可 阅读(43) 评论(0) 推荐(0)
摘要:sicp每日一题[2.51]Exercise2.51 Define the below operation for painters. below takes two painters as arguments. The resulting painter, given a frame, draws with the firs 阅读全文
posted @ 2024-10-21 08:46 再思即可 阅读(30) 评论(0) 推荐(0)
摘要:sicp每日一题[2.52]Exercise 2.52 Make changes to the square limit of wave shown in Figure 2.9 by working at each of the levels described above. In particular: a. Add som 阅读全文
posted @ 2024-10-22 10:44 再思即可 阅读(31) 评论(0) 推荐(0)
摘要:sicp每日一题[2.53-2.55]2.53不用写代码,2.54和2.55属于一道题,所以就放到一起吧 Exercise2.53 What would the interpreter print in response to evaluating each of the following expressions? (list 'a 阅读全文
posted @ 2024-10-23 08:24 再思即可 阅读(42) 评论(0) 推荐(0)
摘要:sicp每日一题[2.56]Exercise 2.56 Show how to extend the basic differentiator to handle more kinds of expressions. For instance, implement the differentiation rule d(x^n) 阅读全文
posted @ 2024-10-24 08:20 再思即可 阅读(32) 评论(0) 推荐(0)
摘要:sicp每日一题[2.57]Exercise 2.57 Extend the differentiation program to handle sums and products of arbitrary numbers of (two or more) terms. Then the last example above 阅读全文
posted @ 2024-10-25 08:30 再思即可 阅读(23) 评论(0) 推荐(0)
摘要:sicp每日一题[2.58]Exercise 2.58 Suppose we want to modify the differentiation program so that it works with ordinary mathematical notation, in which + and * are infix r 阅读全文
posted @ 2024-10-26 13:16 再思即可 阅读(54) 评论(0) 推荐(0)
摘要:sicp每日一题[2.59]Exercise 2.59 Implement the union-set operation for the unordered-list representation of sets. 这道题很简单,仿照 intersection-set 稍作修改就可以实现了 (define (union-se 阅读全文
posted @ 2024-10-27 09:09 再思即可 阅读(34) 评论(0) 推荐(0)
摘要:sicp每日一题[2.60]Exercise2.60 We specified that a set would be represented as a list with no duplicates. Now suppose we allow duplicates. For instance, the set {1, 2, 阅读全文
posted @ 2024-10-28 08:40 再思即可 阅读(27) 评论(0) 推荐(0)
摘要:sicp每日一题[2.61]Exercise 2.61 Give an implementation of adjoin-set using the ordered representation. By analogy with element-of-set? show how to take advantage of the 阅读全文
posted @ 2024-10-29 08:17 再思即可 阅读(33) 评论(0) 推荐(0)
摘要:sicp每日一题[2.62]Exercise 2.62 Give a (n) implementation of union-set for sets represented as ordered lists. 这道题难度也不大,思路是依次从两个集合中取第一个元素,比较他们的大小,把小的那个和剩下所有元素连接的结果连接起来。由 阅读全文
posted @ 2024-10-30 08:07 再思即可 阅读(25) 评论(0) 推荐(0)
摘要:sicp每日一题[2.63-2.64]Exercise 2.63 Each of the following two procedures converts a binary tree to a list. (define (tree->list-1 tree) (if (null? tree) '() (append (tree->l 阅读全文
posted @ 2024-10-31 08:40 再思即可 阅读(43) 评论(0) 推荐(0)
摘要:sicp每日一题[2.65]Exercise 2.65 Use the results of Exercise 2.63 and Exercise 2.64 to give (n) implementations of union-set and intersection-set for sets implemented as 阅读全文
posted @ 2024-11-01 08:42 再思即可 阅读(33) 评论(0) 推荐(0)
摘要:sicp每日一题[2.66]Exercise 2.66 Implement the lookup procedure for the case where the set of records is structured as a binary tree, ordered by the numerical values of 阅读全文
posted @ 2024-11-02 11:31 再思即可 阅读(25) 评论(0) 推荐(0)
摘要:sicp每日一题[2.67-2.68]Exercise 2.67 Define an encoding tree and a sample message: (define (make-leaf-set pairs) (if (null? pairs) '() (let ((pair (car pairs))) (adjoin-set 阅读全文
posted @ 2024-11-03 08:59 再思即可 阅读(26) 评论(0) 推荐(0)
摘要:sicp每日一题[2.69]Exercise 2.69 The following procedure takes as its argument a list of symbol-frequency pairs (where no symbol appears in more than one pair) and gener 阅读全文
posted @ 2024-11-04 19:55 再思即可 阅读(41) 评论(0) 推荐(0)
摘要:sicp每日一题[2.70]Exercise 2.70 The following eight-symbol alphabet with associated relative frequencies was designed to efficiently encode the lyrics of 1950s rock son 阅读全文
posted @ 2024-11-05 20:37 再思即可 阅读(25) 评论(0) 推荐(0)
摘要:sicp每日一题[2.71]Exercise 2.71 Suppose we have a Huffman tree for an alphabet of n symbols, and that the relative frequencies of the symbols are 1,2,4, . . . ,2n 1. Sk 阅读全文
posted @ 2024-11-06 22:03 再思即可 阅读(37) 评论(0) 推荐(0)
摘要:sicp每日一题[2.72]Exercise 2.72 Consider the encoding procedure that you designed in Exercise 2.68. What is the order of growth in the number of steps needed to encode 阅读全文
posted @ 2024-11-07 18:43 再思即可 阅读(23) 评论(0) 推荐(0)
摘要:sicp每日一题[2.73]最近状态不太好,再加上2.73前面的内容有点多,学的有点吃力,所以昨天就没做。。 Exercise 2.73 Section 2.3.2 described a program that performs symbolic differentiation: (define (deriv exp va 阅读全文
posted @ 2024-11-09 22:20 再思即可 阅读(31) 评论(0) 推荐(0)
摘要:sicp每日一题[2.74]Exercise 2.74 Insatiable Enterprises, Inc., is a highly decentralized conglomerate company consisting of a large number of independent divisions locat 阅读全文
posted @ 2024-11-11 19:43 再思即可 阅读(37) 评论(0) 推荐(0)
摘要:sicp每日一题[2.75]Exercise2.75 Implement the constructor make-from-mag-ang in message-passing style. This procedure should be an alogous to the make-from-real-imag proc 阅读全文
posted @ 2024-11-12 19:52 再思即可 阅读(34) 评论(0) 推荐(0)
摘要:sicp每日一题[2.76]Exercise 2.76 As a large system with generic operations evolves, new types of data objects or new operations may be needed. For each of the three stra 阅读全文
posted @ 2024-11-13 19:30 再思即可 阅读(269) 评论(0) 推荐(0)
摘要:sicp每日一题[2.77]Exercise 2.77 Louis Reasoner tries to evaluate the expression (magnitude z) where z is the object shown in Figure 2.24. To his surprise, instead of th 阅读全文
posted @ 2024-11-14 19:37 再思即可 阅读(257) 评论(0) 推荐(0)
摘要:sicp每日一题[2.78]Exercise2.78 The internal procedures in the scheme-number package are essentially nothing more than calls to the primitive procedures +, -, etc. It wa 阅读全文
posted @ 2024-11-15 19:24 再思即可 阅读(252) 评论(0) 推荐(0)
摘要:sicp每日一题[2.79]Exercise2.79 Define a generic equality predicate equ? that tests the equality of two numbers, and install it in the generic arithmetic package. This o 阅读全文
posted @ 2024-11-16 13:23 再思即可 阅读(238) 评论(0) 推荐(0)
摘要:sicp每日一题[2.80]Exercise 2.80 Define a generic predicate =zero? that tests if its argument is zero, and install it in the generic arithmetic package. This operation s 阅读全文
posted @ 2024-11-17 08:57 再思即可 阅读(229) 评论(0) 推荐(0)
摘要:sicp每日一题[2.81]Exercise2.81 Louis Reasoner has noticed that apply-generic may try to coerce the arguments to each other’s type even if they already have the same typ 阅读全文
posted @ 2024-11-18 08:39 再思即可 阅读(260) 评论(0) 推荐(0)
摘要:sicp每日一题[2.82]Exercise 2.82 Show how to generalize apply-generic to handle coercion in the general case of multiple arguments. One strategy is to attempt to coerce 阅读全文
posted @ 2024-11-19 08:59 再思即可 阅读(255) 评论(0) 推荐(0)
摘要:sicp每日一题[2.83]Exercise 2.83 Suppose you are designing a generic arithmetic system for dealing with the tower of types shown in Figure 2.25: integer, rational, real, 阅读全文
posted @ 2024-11-20 08:10 再思即可 阅读(272) 评论(0) 推荐(0)
摘要:sicp每日一题[2.84]Exercise 2.84 Using the raise operation of Exercise 2.83, modify the apply-generic procedure so that it coerces its arguments to have the same type by 阅读全文
posted @ 2024-11-21 08:41 再思即可 阅读(257) 评论(0) 推荐(0)
摘要:sicp每日一题[2.85-2.86]从 2.83 开始我感觉做的有点怪怪的,我似乎没有很好地理解这些题目的目的,也没有在写完之后用测试样例监测,只是简单的实现了那个逻辑。所以做到练习 2.85 我已经不知道在干什么了,所以我决定重新写一遍,把实数这一层也加上,同时每道题目新增的过程都要有对应的测试样例。 结果写了两天也没写出来,参考别 阅读全文
posted @ 2024-11-23 14:07 再思即可 阅读(248) 评论(0) 推荐(0)