Skip to content

Instantly share code, notes, and snippets.

@firstspring1845
Last active August 29, 2015 14:11
Show Gist options
  • Save firstspring1845/e6137fdfe6a895fc133e to your computer and use it in GitHub Desktop.
Save firstspring1845/e6137fdfe6a895fc133e to your computer and use it in GitHub Desktop.
マジなマージ
(defun take (n list)
(if (= n 0) nil (cons (car list) (take (- n 1) (cdr list)))))
(defun slice (n list)
(if (null list) nil (cons (take n list) (slice n (nthcdr n list)))))
(defun msort(list pred)
(cond ((not (consp (car list)))
(msort (slice 1 list) pred))
((equal (cdr list) NIL)
(car list))
(t
(msort (mapcar (lambda (l) (merge 'list (car l) (cadr l) pred))
(slice 2 list))
pred))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment