This isn't a difficult problem, but may be a good way to explore some corners of your Lisp that you otherwise haven't touched yet. It's also a tool with a practical application (if you're curious what the weather is like).

Please don't post any code until Monday June 15th, to allow others a chance to stew over the problem a bit.

Bonus: Allow a choice between English and Metric units.Bonus^2: Print other current weather conditions in addition to temperature.Bonus^4: Print a complete weather forecast.

I thought about your quiz question over coffee. I've never dealt with XML in lisp before, or web interfaces so I thought it might be fun to see how much is involved. Luckily people have thought about this sort of problem and come up with some neat programs.

So, here is some terrible, terrible code using drakma and cxml to do the simple task you asked:

This is the first time I've used either library (and many of their dependencies, it seems) so I'm probably going about it all wrong.

Also, the code is horribly brittle and shouldn't be though of as anything but a proof of concept. Someone with more time that I have at the moment could write something fairly straightforward to unmarshall these xml structures properly into classes and do more interesting things with them....

Anyway, it has no error recovery, no flexibility, no validation, and makes unreasonable assumptions about the data, but at least it works with different queries:

Enough people to make it interesting, at least. Your code looks good to me. I've heard good things about CXML recently so I was interested to see what people would do with it. I didn't know about Drakma at all; it's cool that it's so easy to fetch the contents of a URL in CL.

Here's my Clojure code. My first attempt (at the bottom of the source code) uses Yahoo weather's RSS feed, which requires a US ZIP code or worldwide weather-station code. Wunderground looks like it has a better API for querying cities and I liked your code so I ported it to Clojure for comparison, also included below.

Small suggestion: How about making a class or some sort of "interface" that defines standard stuff for weather? I noticed that the two code examples above are using two different sources for the weather info but their output is nearly the same.