lisp code for sorts?

The first of the following lisp code works, but the second does not, w/ error message of rejected function mid. ;;;sorts two element sublists and makes set.(defun sort_2_to_set (l)(defun big (l) (apply 'max l))(defun small (l) (apply 'min l))(setq lmax (mapcar 'big l))(setq lmin (mapcar 'small l))(setq sortl (mapcar 'list lmin lmax))(setq setl '() len (length l))(repeat len (if (member (car sortl) (cdr sortl)) (setq sortl (cdr sortl));;;else(setq setl (cons (car sortl) setl) sortl (cdr sortl))))(princ));;;end defun sort_2_to_set(setq l '((1 3) (2 5) (7 3) (10 7) (2 7) (8 2) (7 2) (5 2)));;;sorts three element sublists and makes set.(defun sort_3_to_set (l)(defun big (l) (apply 'max l))(defun small (l) (apply 'min l))(setq lmax (mapcar 'big l))(setq lmin (mapcar 'small l))(defun mid (l1 l2 l3) (foreach var l2 (if (and (/= var l1) (/= var l3)) (var))))(setq lmid (mapcar 'mid lmin l lmax))(setq sortl (mapcar 'list lmin lmid lmax))(setq setl '() len (length l))(repeat len (if (member (car sortl) (cdr sortl)) (setq sortl (cdr sortl));;;else(setq setl (cons (car sortl) setl) sortl (cdr sortl))));;;end if, end repeat(princ));;;end defun sort_3_to_set(setq l '((1 2 3) (2 7 5) (7 9 3) (10 4 7) (2 8 7) (8 3 2) (7 5 2) (5 7 2)))any ideas or alternate schemes? Thanks

Comments

  • This worls for what didn't before (?).;;;sorts three element sublists and makes set.(defun sortoset3 (l)(defun maxval (l) (apply 'max l));;;end defun maxval(defun minval (l) (apply 'min l));;;end defun minval(setq lmax (mapcar 'maxval l))(setq lmin (mapcar 'minval l))(setq lmid '() set3 '() len (length l))(defun midval (l)(repeat len (progn (setq nsub (car l) big (apply 'max nsub) small (apply 'min nsub))(foreach var nsub (if (and (/= var big) (/= var small)) (setq lmid (cons var lmid))))(setq l (cdr l)))));;;end defun midval(midval l)(setq lmid (reverse lmid))(setq sortl (mapcar 'list lmin lmid lmax))(repeat len (if (member (car sortl) (cdr sortl)) (setq sortl (cdr sortl));;;else(setq set3 (cons (car sortl) set3) sortl (cdr sortl))));;;end if, end repeat(princ));;;end defun sortoset3

This discussion has been closed.