[Gardeners] Lisp for imperative algorithms (was: The myth about Lisp code being 'write only')
Peter Seibel
peter at gigamonkeys.com
Mon Jun 26 13:57:56 CDT 2006
On Jun 26, 2006, at 8:51 AM, Pablo Barenbaum wrote:
>> IMO, part of the problem is that lisp doesn't map well to the
>> pseudo-code
>> that most non-lispers have in their heads.
>
> Is pseudo-code from books obsolete for Lisp?
> (It doesn't seem to me that all those algorithms are obsolete;
> perhaps,
> with time, literature will adopt a more lispic style, just as
> programming
> languages have).
Well, I find that Common Lisp is an excellent language for dealing
with pseudo-code because it provides many different control
constructs. For an example look at the section "Local Flow of
Control" from chapter 20 of Practical Common Lisp[1] where I show how
you can create a very literal translation of some very low-level
pseudo code from Knuth's _Art of Programming_ and then transform it
into "regular" Lisp code. The nice thing is that the first version,
which is a quite literal translation of Knuth's code, is something
you can actually run and test. Then you can refactor bit by bit and
know that you've always got a working version.
-Peter
[1] <http://www.gigamonkeys.com/book/the-special-operators.html>
--
Peter Seibel * peter at gigamonkeys.com
Gigamonkeys Consulting * http://www.gigamonkeys.com/
Practical Common Lisp * http://www.gigamonkeys.com/book/
More information about the Gardeners
mailing list