Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (small- lst)
- (define (helper lst m)
- (cond
- ((and (null? (cdr lst))(< m (car lst))) m)
- ((and (null? (cdr lst))(> m (car lst)))(car lst))
- ((< m (car lst))(helper (cdr lst) m))
- ((> m (car lst))(helper (cdr lst)(car lst)))))
- (helper (cdr lst)(car lst)))
- (define (remove- lst remove-me)
- (cond
- ((null? lst)'())
- ((eq? (car lst) remove-me)(cdr lst))
- (else
- (cons (car lst)(remove- (cdr lst) remove-me)))))
- (define (order- lst)
- (cond
- ((null? (cdr lst))(cons (car lst)'()))
- (else
- (let ((small (small- lst)))
- (let ((remain (remove- lst small)))
- (cons small (order- remain)))))))
- (define (order- lst)
- (define (helper lst final-lst)
- (cond
- ((null? (cdr lst))(cons (car lst) final-lst))
- (else
- (let ((small (small- lst)))
- (let ((remain (remove- lst small)))
- (helper remain (cons small final-lst)))))))
- (helper (remove- lst (small- lst))(cons (small- lst)'())))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement