Learning Lisp

The Road To Lisp

Lisp Web Applications

Posted by j1p on May 3, 2006

After a bunch of reading on implementations of Lisp solutions, and thinking a bit about how I would benefit the most from learning Lisp, I have decided I should look at it in the perspective of web-based applications.

It seems that any program I could develop(not that I am in any way ready to develop a distributable program) would be limited to Linux machines, which is not exactly the best way to reach users. I will, of course, learn the basics that would necessary to develop these applications, but I think I will take on the web-based perspective.

After realizing this, I looked at a few solutions for Lisp on the web. Things such as the UnCommon Web, TBNL, and Araneida. You may remember the question I posed at the end of the last post, about which Common Lisp implementation a beginner Lisper(is that the right term?) should use. With these solutions being some of the most common possibilities, I chose SBCL, for a variety of reasons. For one, these Lisp Web Servers seem to integrate very well with SBCL. Another reason is SBCL seems a powerful, popular CL implementation, with features such as threading.

I plan to set up some kind of local test server running one, or a combination of these solutions on my Ubuntu box in the next two weeks, as my semester at University is ending. Speaking of school, after next year I will have fulfilled the prerequisites to the AI and Robotics classes, both of which touch on Lisp, and are taught by a very knowledgeable professor.

Now, back to my road to learning the skills I actually need to complete any of my various dreams of hacking in Lisp:

At work this morning I sat down and read through the first few parts of The CLOS Perspective, which was my first introduction to object orientated programming in Lisp. Unfortunately, the book is not very focused on "teaching" how to program with CLOS, but by the few code snippets in the first few sections, it looked pretty simple, and similar to defining functions, with a little more added. I'll have to find a better book on teaching CLOS, or an online tutorial of the sort.

I've read through the parts of Steele's book that correspond to the points I've learned through Winston and Horn's Lisp. In Lisp, I've finished Chapters 2 and 3. I've learned all about association lists, some more advanced mathematical functions (round, expt, sqrt, abs, max, min) by finishing chapter 2, and believe I've mastered the (simple) list manipulation functions.

Here are the rest of the sample problems from Chapter 2:

Problem 2-8: Evaluate the following forms

  1. (length '(plato socrates aristotle))
  2. (length '((plato) (socrates) (aristotle)))
  3. (length '((plato socrates aristotle)))
  4. (reverse '(plato socrates aristotle))
  5. (reverse '((plato) (socrates) (aristotle)))
  6. (reverse '((plato socrates aristotle)))

Problem 2-9: Evaluate the following forms

  1. (length '((car chevrolet) (drink coke) (cereal wheaties)))
  2. (reverse '((car chevrolet) (drink coke) (cereal wheaties)))
  3. (append '((car chevrolet) (drink coke)) (reverse '((car chevrolet) (drink coke)))) — hard to format correctly, sorry!

Problem 2-10: Evaluate the following forms

  1. (/ (+ 3 1) (- 3 1))
  2. (* (max 3 4 5) (min 3 4 5))
  3. (min (max 3 1 4) (max 2 7 1))

Chapter Two Summary (main points)

  • LISP means symbol manipulation
  • LISP procedures and data are symbolic expressions
  • Lists are like bowls
  • FIRST and REST take lists apart
  • Quoting stops evaluation
  • Some "old timers" use CARs and CDRs
  • SETF assigns values to symbols
  • SETF accepts multiple symbol-value pairs
  • Certain atoms evaluate to themselves (t and nil)
  • CONS, APPEND, and LIST construct lists
  • CONS, APPEND, and LIST do not alter symbol values
  • NTHCDR, BUTLAST, and LAST shorten lists
  • LENGTH and REVERSE work on top-level elements
  • ASSOC looks for indexed sublists
  • LISP offers integers, ratios, and floating point numbers, among others
  • A few primitives for numbers round out a basic repertoire

Chapter 2 was basically a run-down of what I had already learned through the first few chapters of online tutorials, so it didn't challenge me much, and Chapter 3 was also mostly the same. Chapter 3, titles Procedure Definition and Binding, introduced functions, and the Lisp primitives; defun and let.

I don't have much time to cover Chapter 3 tonight, as I have 3 papers and 4 finals in the next two weeks, and its getting late. I'll try to post about chapter 3 and anything I read tomorrow by Thursday.

A question for you readers(if you exist): Which setup of a Lisp webserver would you recommend me. I have set up a few Apache2 servers before, so I have some experience in the area, but would prefer a not-impossible set-up, and decent feature-set. As I am just learning, I obviously don't need features that would only benefit the most advanced of applications, but it would be nice to have some power while building my skills.

Answers to sample problems in last post(please correct me if I get some of the wrong, I am just learning):

Problem 2-1:

  1. Atom
  2. List(of the atoms THIS, IS, AN, ATOM)
  3. List(of the atoms THIS, IS, AN, EXPRESSION)
  4. Neither(ill formed parenthesis)
  5. List(of the atoms LIST, 3)
  6. List(of the atom /, and Lists (+ 3 1) (- 3 1)
  7. Neither(ill formed parenthesis)
  8. List(of a List of a Empty List)
  9. List(of two empty Lists)
  10. Neither(closing parenthesis don't match opening parenthesis)
  11. Neither(ill formed parenthesis)
  12. Neither(no closing parenthesis)

Problem 2-2

  1. P
  2. (K P H)
  3. (A B)
  4. (C D)
  5. (C D)
  6. (B)
  7. (D)
  8. B

Problem 2-3

  1. D
  2. E
  3. (A B)
  4. This gave me an error when I put it into SBCL, The value REST is not of type LIST.
  5. FIRST
  6. (FIRST (FIRST (REST (REST ((A B) (C D) (E F))))))

Problem 2-4 (assume *list* is set to the list in question.

  1. (first (rest (rest *list*)))
  2. (first (first (rest *list*)))
  3. (first (first (rest (rest *list*))))
  4. (first (first (first (rest (rest *list*)))))
  5. (first (first (rest (rest *list*))))
  6. (first (rest (first *list*)))

Problem 2-5

  1. (A B C)
  2. ((A B C) NIL)
  3. ((A B C))

Problem 2-6


Problem 2-7

  • (NIL)

2 Responses to “Lisp Web Applications”

  1. This is the first time I comment here and I should say that you give genuine, and quality information for other bloggers! Great job.
    p.s. You have an awesome template for your blog. Where have you got it from?

  2. news said

    Awesome post ! Thank you for, commenting on my blog dude. I will message you some time! I didnt realise that.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: