(defmacro for-all (x op xs)
`(remove-if-not #'(lambda (y) (,op y x)) xs))
(defun qsort (nums)
(if (not nums)
()
(let ((x (first nums))
(xs (rest nums)))
(if (eq x nil)
()
(append
(qsort (for-all x < xs))
(list x)
(qsort (for-all x >= xs)))))))
Permutation
(defun remove-first (n nums)
(remove n nums :count 1))
(defun join-sublists (superlist)
(reduce #'(lambda (l1 l2) (append l1 l2)) superlist))
(defun permute-sorted-list (nums perm)
(if (eq nums nil)
(list perm)
(let ((unique-nums (remove-duplicates nums))) (join-sublists
(mapcar (lambda (n)
(permute-sorted-list (remove-first n nums) (append perm (list n))))
unique-nums)))))
(defun permutation (nums)
(permute-sorted-list (sort nums #'<) '()))
13 則留言:
You are terrific. I like this remarkable things, Keep it up and keep on writing
I like to see some other posts on the same subject! Very useful informative info!!
I must thank you for the efforts you’ve put in writing this blog. Awesome!
You’ve written nice post, I am gonna bookmark this page, thanks for info.
Hi very nice blog! I'll bookmark this website. Thanks for blogging.
Thanks for sharing your info. I truly appreciate your efforts
and I will be waiting for your next write ups thanks once again.
Some truly quality articles on this website , bookmarked .
Just want to say your article is as surprising.
Hi there, I enjoy reading all of your post. I wanted to write a little comment to support you.
As I website possessor I believe the articles here is very excellent, thanks for your efforts.
Hello there! D.
This post could not be written any better! D.
Reading through this post reminds me of my previous roommate! D.
張貼留言