Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Spoiler: LISP is useless

Name: Anonymous 2009-10-28 21:29

Name one noteworthy program that was coded in LISP.

I'll wait.

Name: Anonymous 2009-10-29 6:14

>>22
The program made use of CL's extensive list functions, such as: MAPLIST PUSH CONS FIRST/REST/CAR/CDR/CDAR SORT SET-DIFFERENCE REMOVE NREVERSE and some others, to implement a simple grpah manipulation algorithm. The C version had done the same things, but in an ad-hoc manner, leading to a lot of code duplication. I'm sure I could have factored away most of the similar code patterns, had I known Lisp before I wrote the C version, but alas that was a long time ago. Here's a sample of one of the functions used by it:


(defun seq (n m)
  (loop for i from n to m collect i))

(defun compute-graph
    (removal-order &optional (n (+ 2 (length removal-order))))
  (let ((vertex-bag (seq 1 n))
        edges)                
    (maplist #'(lambda (order)                                 
                 (push
                  (cons                      
                   (let ((next-vertex
                          (first (sort (set-difference vertex-bag order) #'<))))
                     (setf vertex-bag (remove next-vertex vertex-bag))
                     next-vertex)                          
                   (first order))
                  edges))
             removal-order)
    (let ((last-vertex (cdar edges)))
      (push (cons (car (remove last-vertex vertex-bag))
                  last-vertex) edges))
    (nreverse edges)))


The C program did something similar among other things it did, but it wasn't solving the same thing as this Lisp one, however it was similar.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List