`
zhangle
  • 浏览: 26597 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论
文章列表
Hibernate中,对于domain model之间的父子关系,有时需要父对象需要得知子对象的数目,常规的做法是用一条sql语句"select count(*) ..."。 更好的做法可以借鉴RoR,在父对象中设置一个保存子对象数目的字段,添加删除的时候对这个字段进行更新。 但对这个字段进行更新的时候,往往需要显式的对父对象进行更新,比如create Topic时需要: User user = this.userDao.get(userId); Topic topic = new Topic(user); this.topicDao.create(topic); ...
window 模式 默认情况下的显示模式,在这种模式下flash player有自己的窗口句柄,这就意味着flash影片是存在于Windows中的一个显示实例,并且是在浏览器核心显示窗口之上的,所以flash只 是貌似显示在浏览器中,但这也是flash最快最有效率的渲染模式。由于他是独立于浏览器的HTML渲染表面,这就导致默认显示方式下flash总是会遮 住位置与他重合的所有DHTML层。 但是大多数苹果电脑浏览器会允许DHTML层显示在flash之上,但当flash影片播放时会出现比较诡异的现象,比如DHTML层像被flash刮掉一块一样显示异常。 Opaque 模式 这是一种无窗口模 ...
2.26 (define x (list 1 2 3)) (define y (list 4 5 6)) (append x y) (cons x y) (list x y) (define z (list x y)) (car z) (cdr z) 2.27 (define nil '()) (define (my-reverse x) (if (null? x) nil (append (my-reverse (cdr x)) (list (car x))))) (define (deep-reverse ls ...
2.21 (define nil '()) (define (square x) (* x x)) (define (square-list items) (if (null? items) nil (cons (square (car items)) (square-list (cdr items))))) (define (square-list-map items) (map (lambda (x) (square x)) items)) (square-list (list 1 2 3 4)) (square ...

sicp 习题 2.17 ~ 2.20

    博客分类:
  • SICP
2.17 (define (my-last-pair l) (if (null? (cdr l)) (car l) (last-pair (cdr l)))) (my-last-pair (list 23 72 149 34)) 2.18 (define (my-reverse l) (if (or (null? l) (= (length l) 1)) l (append (my-reverse (cdr l)) (list (car l))))) (my-reverse (list 23 72)) ...
2.12 (define (add-interval x y) (make-interval (+ (lower-bound x) (lower-bound y)) (+ (upper-bound x) (upper-bound y)))) (define (sub-interval x y) (add-interval x (make-interval (- 0 (lower-bound y)) (- 0 (upper-bound y))))) (define (mul-interval x y) (let ((p1 (* ...
以下是double-checked locking的java代码: public class Singleton { private Singleton instance = null; public static Singleton getInstance() { if (instance == null) { synchronized(this) { if (instance == null) { instance = new Singleton() ...

sicp 习题 2.6 ~ 2.10

    博客分类:
  • SICP
2.6 (define zero (lambda (f) (lambda (x) x))) (define (add-1 n) (lambda (f) (lambda (x) (f ((n f) x))))) ((zero 4) 3) (add-1 5 1) 2.7 (define (add-interval x y) (make-interval (+ (lower-bound x) (lower-bound y)) (+ (upper-bound x) (upper-bound y)))) (define (mul-inte ...
2.1 (define (make-rat n d) (let ((g (gcd n d))) (cond ((and (< n 0) (> d 0)) (cons (/ n g) (/ d g))) ((and (> n 0) (> d 0)) (cons (/ n g) (/ d g))) (else (cons (/ (- n) g) (/ (- d) g))) ))) (define (numer x) (car x)) (define (denom x) (cdr x)) ( ...

sicp 习题 1.42 ~ 1.46

    博客分类:
  • SICP
1.42 (define (my-compose f g) (lambda (x) (f (g x)))) (define (inc x) (+ x 1)) (define (square x) (* x x)) ((my-compose square inc) 6) 1.43 (define (my-compose f g) (lambda (x) (f (g x)))) (define (inc x) (+ x 1)) (define (square x) (* x x)) ((my-compose ...
1.38 (define (cont-frac n d i k) (if (= k 1) (/ (n 1) (d 1)) (/ (n i) (+ (d i) (cont-frac n d (+ i 1) (- k 1)))))) (define (cont-frac-r n d k) (define (frac i) (if (= i (+ k 1)) 0 (/ (n i) (+ (d i) (frac (+ i 1)))))) (frac 1)) (define (cont-frac-i n ...

sicp 习题 1.34 ~ 1.37

    博客分类:
  • SICP
1.34 (define (square n) (* n n)) (define (f g) (g 2)) (f square) (f (lambda (z) (* z (+ z 1)))) (f f) 1.35 (define tolerance 0.00001) (define (fixed-point f first-guess) (define (close-enough? v1 v2) (< (abs (- v1 v2)) tolerance)) (define (try guess) (let ((ne ...

sicp 习题 1.29 ~ 1.33

    博客分类:
  • SICP
1.29 (define (inc n) (+ n 1)) (define (cube a) (* a a a)) (define (sum term a next b) (if (> a b) 0 (+ (term a) (sum term (next a) next b)))) (define (sum-cubes a b) (sum cube a inc b)) (define (integral f a b dx) (define (add-dx x) (+ x dx)) (* (sum ...

sicp 习题 1.21 ~ 1.22

    博客分类:
  • SICP
1.21 (define (smallest-divisor n) (find-divisor n 2)) (define (find-divisor n test-divisor) (cond ((> (square test-divisor) n) n) ((divides? test-divisor n) test-divisor) (else (find-divisor n (+ test-divisor 1))))) (define (square n) (* n n)) (define (divides? ...
1.10 (define (A x y) (cond ((= y 0) 0) ((= x 0) (* 2 y)) ((= y 1) 2) (else (A (- x 1) (A x (- y 1)))))) (define (f n) (A 0 n)) (define (fm n) (* 2 n)) (define (g n) (A 1 n)) (define (gm n) (if (= n 1) 2 (* 2 (gm (- n 1))))) (de ...
Global site tag (gtag.js) - Google Analytics