Lisp
Want to learn LISP on Mac OS X
Recently you may have noticed a certain amout of blog.love of Paul Graham . What can I say, I really liked his book Hackers and Painters.
He talks somewhat extensively about the programming language LISP. To this end I have taken up the challenge and am now working through his instructional book ANSI Common Lisp.
Here is how I managed to get an emacs-based IDE running Common Lisp.
You need this web page for background: [ LINK ].
Download fink if you don’t have it. This is a handy tool for grabbing new command-line-ish tools
Make sure you can get clisp: “sudo fink list clisp” - something should come back with the word clisp in it.
A weekend spent battling Lisp
Well maybe I should make sure that I use a positive word, instead of “battling” I should say “becoming more acquainted with” Lisp.
This stuff reminds me so much of my symbolic logic class back in school, the material is dense, the explanation is denser, and virtually all the best part of the learning is left as an exercise to the reader, his supply of ink, and his supply of paper.
As such, I have spent many hours trying to accomplish but a few problems or feel comfortable in being able to model the world according to the syntax of Lisp.
Lisp problem solved
There are many ways do skin a cat, but here’s how I handled the occurrences task…
Answer
>(occurrences '(a b a d a c d c a)) ((A . 4) (C . 2) (D . 2) (B . 1)) See, it retuns the token (A, B, etc.) and how many times it occurred
Code
(defun occurrences (queue) (sort-count-pairs (scan-queue queue () () ) )) (defun scan-queue (aQueue aSearched aCount) (if (null (car aQueue)) aCount (progn (if (member (car aQueue) aSearched) (scan-queue (cdr aQueue) aSearched aCount) (let ((scantoken (car aQueue))) (push scantoken aSearched) (push (count-token scantoken aQueue 0) aCount) (scan-queue (cdr aQueue) aSearched aCount)))))) (defun count-token (sToken aQ count) (if (null (car aQ)) (cons count sToken) (progn (if (equal (car aQ) sToken ) (setf count (+ count 1))) (count-token sToken (cdr aQ) count)))) (defun sort-count-pairs (pairs) (let ((sortcount (mapcar #'(lambda (x) (car x)) pairs))) (sort sortcount #'>) (mapcar #'(lambda (x) (let ((mypair (assoc x pairs))) (setf pairs (remove (assoc x pairs) pairs)) (cons (cdr mypair) (car mypair)))) sortcount)))
Great news for Lispers!
For all of you thinking about taking a loot at Lisp, the guys over at Gigamonkeys have build a pretty handy tool for getting started with at quickness. Download and check it out (OS X and Linux. Windows, as ever, lags).
Feeling Code's Consequences
On tightening the feedback loop between programmers and a feedback canvas: from
Adam Vermeer’s “badspreadsheet” (2024) to Brett Victor’s prototypes (~2014,
left image) to Medley Interlisp (~1986).