This is a collection of blog entries written while learning Lisp. It is posted in the order written so you probably want to jump to the first post.

Monday, October 22, 2007

Practical Common Lisp Chapter 12 : List Processing

Twelve chapters in we are finally introduced to car and crd. I didn't realize the first/rest car/crd correlation before today which is of course blindly obvious now. Props to the author for delaying this longer then most authors. There was also a nice little bit of history and explanation. The neat new (to me) stuff in this chapter was the section on "Destructive Operations". From the book:

for-side-effect operations - For example setf will modify a list

recycling operations - For example "nreverse x" is a recycling operation because it will return x after moving around the pointers rather then creating a whole new list like reverse does.

When doing functional programming you don't normally use destructive operations, but recycling operations are useful as an optimizing technique. But you should of course be careful with them.

It took about six reads through the section and a dozen re-writes of this blog entry to figure the above out. Don't worry if you don't get it the first time. It is a very confusing section. I have to say writing this blog has been very helpful just be forcing me to write out what I think I just learned. :)

No comments: