I’m currently taking (online) MIT’s algorithms course. I needed a good brush-up on algorithms, starting with the basic theory. I’m going to jump in to help a buddy working on a graph database in lisp Vivace Graph, which should be an open source competitor to AllegroGraph. Allegro has probably the best graph db out there right now. There are some competitors in the java world, but they are either expensive or don’t provide enough features, or don’t provide APIs outside of java. Allegro has an extensive list of client libs. I’ll write up more on the graph db in some future, for now, I got back into lisp and implemented the simplest alg (merge sort) in it.
The reason I’m posting is to get some comments. I’d love to hear your thoughts on how a lisp nOOb can improve this ![]()
(defun merge-sort (lst) (let ((size (length lst))) (if (= size 1) lst (progn (let ((seq1 (merge-sort (subseq lst 0 (floor (/ size 2))))) (seq2 (merge-sort (subseq lst (floor (/ size 2)) size)))) (merge-it seq1 seq2))))))
(defun merge-it (l1 l2) (let ((new-arr (make-array (+ (length l1) (length l2)) :fill-pointer 0))) (loop for idx from 0 to (+ (length l1) (length l2)) do (let ((x (car l1)) (y (car l2))) (when (and (not (null x)) (not (null y))) (if (<= x y) (progn (setf l1 (cdr l1)) (vector-push x new-arr)) (progn (setf l2 (cdr l2)) (vector-push y new-arr)))))) (mapcar #'(lambda (e) (vector-push e new-arr)) (append l1 l2)) (coerce new-arr 'list)))