]]>090310 RHEL 涓嬪畨瑁呭甫mod_prox妯″潡鐨刟pachehttp://www.tkk7.com/lzj520/archive/2009/03/10/258885.htmllzj520lzj520Tue, 10 Mar 2009 11:06:00 GMThttp://www.tkk7.com/lzj520/archive/2009/03/10/258885.htmlhttp://www.tkk7.com/lzj520/comments/258885.htmlhttp://www.tkk7.com/lzj520/archive/2009/03/10/258885.html#Feedback0http://www.tkk7.com/lzj520/comments/commentRss/258885.htmlhttp://www.tkk7.com/lzj520/services/trackbacks/258885.html
make
make install
]]>090310 Exercise 1.11. recursive process and iterativehttp://www.tkk7.com/lzj520/archive/2009/03/10/258516.htmllzj520lzj520Tue, 10 Mar 2009 00:51:00 GMThttp://www.tkk7.com/lzj520/archive/2009/03/10/258516.htmlhttp://www.tkk7.com/lzj520/comments/258516.htmlhttp://www.tkk7.com/lzj520/archive/2009/03/10/258516.html#Feedback0http://www.tkk7.com/lzj520/comments/commentRss/258516.htmlhttp://www.tkk7.com/lzj520/services/trackbacks/258516.htmlExercise 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 that computes f by means of an iterative process.
recursive:
(define (fn n)
(cond ((>= n 3) (+ (+ (fn (- n 1)) (* 2 (fn (- n 2)))) (* 3 (fn (- n 3)))))
((< n 3) n)
))
iterative:
(define (re n)
(if (< n 3)
n
(iter 2 1 0 n)
))
(define (iter a b c n)
(if(= n 3)
(ca a b c)
(iter (ca a b c) a b (- n 1))
)
)
(define (ca a b c)
(+ a (* 2 b) (* 3 c) )
)
]]>090306 Exercise 1.8 cube-root procedureshttp://www.tkk7.com/lzj520/archive/2009/03/06/258241.htmllzj520lzj520Fri, 06 Mar 2009 08:22:00 GMThttp://www.tkk7.com/lzj520/archive/2009/03/06/258241.htmlhttp://www.tkk7.com/lzj520/comments/258241.htmlhttp://www.tkk7.com/lzj520/archive/2009/03/06/258241.html#Feedback0http://www.tkk7.com/lzj520/comments/commentRss/258241.htmlhttp://www.tkk7.com/lzj520/services/trackbacks/258241.html
the cube root of x, then a better approximation is given by the value
(x/y2+2y)/3
Use this formula to implement a cube-root procedure analogous to the square-root procedure. (In
section 1.3.4 we will see how to implement Newton's method in general as an abstraction of these
square-root and cube-root procedures.)
(define (cube x)
(* x x x))
(define (square x)
(* x x ))
(define (result x y)
(/ (+ (/ x (square y)) (* 2 y)) 3))
(define (improve x guess)
(result x guess))
(define (good-enough? x guess)
(< (abs (- (* guess guess guess ) x))0.001))
(define (sqrt-iter x guess)
(if (good-enough? x guess)
guess
(sqrt-iter x (improve x guess)
)))
]]>090306 Exercise 1.6 Square Roots by Newton's Methodhttp://www.tkk7.com/lzj520/archive/2009/03/06/258214.htmllzj520lzj520Fri, 06 Mar 2009 07:19:00 GMThttp://www.tkk7.com/lzj520/archive/2009/03/06/258214.htmlhttp://www.tkk7.com/lzj520/comments/258214.htmlhttp://www.tkk7.com/lzj520/archive/2009/03/06/258214.html#Feedback0http://www.tkk7.com/lzj520/comments/commentRss/258214.htmlhttp://www.tkk7.com/lzj520/services/trackbacks/258214.html
can't I just define it as an ordinary procedure in terms of cond?'' she asks. Alyssa's friend Eva Lu
Ator claims this can indeed be done, and she defines a new version of if:
(define (new-if predicate then-clause else-clause)
(cond (predicate then-clause)
(else else-clause)))
Eva demonstrates the program for Alyssa:
(new-if (= 2 3) 0 5)
5
(new-if (= 1 1) 0 5)
0
Delighted, Alyssa uses new-if to rewrite the square-root program:
32(define (sqrt-iter guess x)
(new-if (good-enough? guess x)
guess
(sqrt-iter (improve guess x)
x)))
What happens when Alyssa attempts to use this to compute square roots? Explain.
]]>090305 Exercise 1.3 returns the sum of the squares of the two larger numbershttp://www.tkk7.com/lzj520/archive/2009/03/05/258058.htmllzj520lzj520Thu, 05 Mar 2009 11:56:00 GMThttp://www.tkk7.com/lzj520/archive/2009/03/05/258058.htmlhttp://www.tkk7.com/lzj520/comments/258058.htmlhttp://www.tkk7.com/lzj520/archive/2009/03/05/258058.html#Feedback0http://www.tkk7.com/lzj520/comments/commentRss/258058.htmlhttp://www.tkk7.com/lzj520/services/trackbacks/258058.html
(define (compare x y) (- x y))
(define (sumsquares x y)(+(* x x)(* y y)))
(define (returnlarge a b c)
(cond ((and (>= (compare a b) 0) (>= (compare c b) 0)) (sumsquares a c))
((and (>= (compare a c) 0) (>= (compare b c) 0)) (sumsquares a b))
((and (>= (compare c a) 0) (>= (compare b a) 0)) (sumsquares b c))
)
)
(returnlarge 3 3 2)
public class ActiveUserListener2 implements HttpSessionListener {
private static int sessionCount2 = 0;
private static Map sessionMaps2 = new HashMap(); //瀛樻斁session鐨勯泦鍚堢被