做了個難的
(define bubble
(lambda (predicate b slst)
(if (null? slst)
(list b)
(if (predicate (car slst) b)
(cons (car (bubble predicate (car slst) (cdr slst)))
(cons b (cdr (bubble predicate (car slst) (cdr slst)))))
(cons (car (bubble predicate b (cdr slst)))
(cons (car slst) (cdr (bubble predicate b (cdr slst)))))))))
;Value: bubble
(define sort
(lambda (predicate lon)
(if (null? lon)
'()
(cons (car (bubble predicate (car lon) (cdr lon)))
(sort predicate (cdr (bubble predicate (car lon) (cdr lon))))))))
;Value: sort
(sort < '(8 2 5 2 3))
;Value 27: (2 2 3 5 8)
(sort >'(8 2 5 2 3))
;Value 28: (8 5 3 2 2)