とりあえずやっつけ。
(define (list-count l)
(cond ((null? l) 0)
(else (+ 1 (list-count (cdr l))))))
(define (one-path l)
(cond
((or (null? l) (null? (cdr l))) l)
((> (car l)(cadr l))(cons (cadr l)
(one-path (cons (car l)(cddr l)))))
(else (cons (car l)(one-path (cdr l))))))
(define (b-sort l num)
(cond ((zero? num) l)
(else (b-sort (one-path l) (- num 1)))))
(define (bubble-sort l)
(cond
((null? l) l)
(else (b-sort l (- (list-count l) 1)))))
No comments:
Post a Comment