Advertisement
Guest User

Untitled

a guest
Oct 16th, 2014
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 1.01 KB | None | 0 0
  1. (defun small- (lst)
  2.   (labels ((helper-small (lst smallest)
  3.          (cond
  4.            ((and (null (cdr lst))(< smallest (car lst)))  smallest)
  5.            ((and (null (cdr lst))(> smallest (car lst)))  (car lst))
  6.            ((< smallest (car lst))(helper-small (cdr lst) smallest))
  7.            (t
  8.         (helper-small (cdr lst)(car lst))))))
  9.   (helper-small (cdr lst)(car lst))))
  10.  
  11. (defun remove- (lst remove-me)
  12.   (cond
  13.     ((null lst)'())
  14.     ((equal (car lst) remove-me)(cdr lst))
  15.     (t
  16.      (cons  (car lst)(remove- (cdr lst) remove-me)))))
  17.  
  18. (defun order- (lst)
  19.   (cond
  20.     ((null (cdr lst))(cons (car lst)()))
  21.     (t (let ((small (small- lst)))
  22.      (let ((remain (remove- lst small)))
  23.        (cons small (order- remain)))))))
  24.  
  25. (defun order- (lst)
  26.   (labels ((helper-order (lst final-lst)
  27.          (cond
  28.            ((null (cdr lst))(cons (car lst) final-lst))
  29.            (t (let ((small (small- lst)))
  30.             (let ((remain (remove- lst small)))
  31.               (helper-order remain (cons small final-lst))))))))
  32.   (helper-order lst ())))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement