yuessiah / 116 Goto Github PK
View Code? Open in Web Editor NEWMy school homeworks
My school homeworks
usage: (merge-sort '(2 1 8 3 2 5 7 9 4 6 9))
merge 和 split-list 是尾端遞迴,
可能爆 stack 是 merge-sort 本身會是 2^n 。
(defun merge (merge-list sort1 sort2)
(cond
((null sort1) (append (reverse merge-list) sort2))
((null sort2) (append (reverse merge-list) sort1))
(t (let ((a1 (car sort1))
(a2 (car sort2)))
(if (< a1 a2)
(merge (cons a1 merge-list)
(cdr sort1)
sort2)
(merge (cons a2 merge-list)
sort1
(cdr sort2)))))))
(defun split-list (list1 list2)
(if (>= (length list1)
(length list2))
(cons list1 list2)
(split-list (cons (car list2) list1)
(cdr list2))))
(defun merge-sort (list)
(let ((list-length (length list)))
(if (= list-length 1)
list
(let* ((pair (split-list '() list))
(list1 (car pair))
(list2 (cdr pair)))
(merge (merge-sort list1)
(merge-sort list2))))))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.