3 ms·
I don't think my own Lisp code is really worth showing off so I'm going to cheat. Here's some impressively awesome Lisp code, that leverages features that migh
by spacemanaki 15y ago
I don't think my own Lisp code is really worth showing off so I'm going to cheat.
Here's some impressively awesome Lisp code, that leverages features that might be considered "too powerful". It's some Common Lisp from Peter Norvig's Paradigms of AI Programming: http://norvig.com/paip/auxfns.lisp http://norvig.com/paip/auxfns.lisp
Checkout any of the macros in that file (search for "defmacro"). If you need a primer on Common Lisp macros I think Peter Seibel's intro is sufficient: http://gigamonkeys.com/book/macros-defining-your-own.html http://gigamonkeys.com/book/macros-defining-your-own.html
The memoization stuff is pretty cool and so is the stuff for managing resources (defresource and with-resource).
That's one of the best books on programming I've ever read (I mean started and set aside then picked up again and again for many months and haven't finished), and there's a lot of really nice and elegant code in it. The way he describes searching graphs and trees is really nice but that code doesn't use any of the really Lispy stuff. It would look pretty similar in Python or Ruby. The rest of the code is here: http://norvig.com/paip/README.html http://norvig.com/paip/README.html