Lisp – wow, that’s a weird feeling.

October 25, 2008

I’ve been holed up in my office lately, teaching myself Common Lisp for an upcoming part of my Ph.D, and I have to tell ya, it’s a weird feeling to write code in Lisp.  I read through Peter Seibel’s great online book Practical Common Lisp, which is an absolutely brilliant resource for first time Lispers, especially those coming from other languages.  (I will admit to a bit of irony, though:  I downloaded the book and wrote a Python script to HTMLize the footnotes into links so that I could jump back and forth without having to continually figure out where the hell I had been when I went to read that note).

In any case, I just finished my first “real” program in Lisp – real in that it was done entirely on my own and required more than 5 lines of code, though the problem I “solved” was an imaginary one.  It’s one of those throwaway efforts to acquaint yourself with a new way of thinking.  I went into it thinking that Lisp was overblown, one of those things that people looked back on fondly with rose-colored glasses while muttering about how “real programmers used to do it”, but by the time I was finished writing the thing, I found that I was actually enjoying myself.  I can’t even explain why, but by the end of writing the program, I was actively looking for new ways to extend the idea so that I could keep writing code!  And now, I find myself looking forward to my next program in Lisp, a far cry from where I started.

(If you’re wondering what I was writing, it’s kind of embarassing, but here it is:  I wrote a program to quantify the cost to typing words on a keyboard from the perspective of a single-finger, one-handed typist.  The “cost” is distance – i.e. how far would the finger have to travel – defined by adjacent keys, so that ‘T’ and ‘E’ are two units apart (‘T’ -> ‘R’ -> ‘E’).  I did this using cl-graph to map the keys onto a graph, and wrote an implementation of Djikstra’s algorithm to calculate the distances between key pairs.  I could then calculate the distance between each pair of letters in a word and sum the distances to get the total cost, which I then averaged over the length of the word so that the penalty for long words was minimized.  After that, it was a snap to write a couple of functions to do things like take in a word list and write out each word with its associated cost, or to get the total cost of a string.  See?  Told you it was trivial. 🙂 )


Here’s something that’s a little bit more fun.

July 25, 2008

Via The Intersection, Yahoo has a list of the top 10 scientifically inaccurate movies.  Of course, something like this is great fodder for those late night conversations when everything makes sense, but it’s fun to page through their choices and snicker at the really bad science in there.

For some reason, this also reminded me of a series of videos by Dr. Jim Kakalios (who wrote the book The Physics of Superheroes) in which he talks about some of the science in comics.  Here’s the video where he discusses the death of Gwen Stacy in Spider-Man;  Kakalios is a great presenter, and it’s a fun topic, so give it a watch.

Here’s some of the other ones as well:

My Seven Deadly Sins…

July 16, 2008

Following the advice of Clay Burell at the Beyond School blog, I took the Seven Deadly Sins quiz to see how my immortal soul is faring.  Here’s the results:

Greed: Very Low
Gluttony: Medium
Wrath: Very Low
Sloth: Very Low
Envy: Very Low
Lust: Medium
Pride: Very Low

Take the Seven Deadly Sins Quiz

Well, at least I have an explanation for why I’m not a six-pack Adonis! And my wife will likely be happy to hear about my Lust score. In fact, I think I’m just going to post this and sign off right now… 🙂

Which browser do *you* use?

May 24, 2008

Via Boing Boing, I saw this pop into my RSS feeds:

Smartest Browser and OS

The IQ League apparently has a 60 second IQ test, which they’re mapping onto their web server logs to trumped the smartest browser, operating system, website referrers, countries, and so on. Of course, IQ is a contentious field to begin with, and things like this tend to anger the ever-lovin’ spit out of psychologists in this area (there’s nothing like the statistical properties of g to get them foaming at the mouth).

But it’s fun to look at, nonetheless…

Random things I’ve come across on the web today.

May 13, 2008