Archive Page 2

Nested Map

I was in the #lisp chat room at Freenode when someone posed a question about performing a map function over a nested lists. This was an interesting problem, so I thought that I would cover it here.

Suppose there was a complex tree of numbers:

((1 2) (3 4))

And you want to map each to a function (let’s say a squaring function) and maintain its structure. This is where a good utility function would be in order. The function must be able to handle trees of an unknown structure. So, the only solution that I know would be to use recursion:

(defun nested-map (fn item)
    (cond ((null item) nil)
          ((atom item)   (funcall fn item))
          ((consp item) (cons (nested-map fn (car item))
                                 (nested-map fn (cdr item))))))

Even though it looks complex, the function seems correct:

CL-USER> (nested-map #'(lambda (x) (* x x))
           '((1 2) (3 4)))
((1 4) (9 16))
CL-USER> (nested-map #'(lambda (x) (* x x))
           '(1 2 (3 4 (5 6 7))))
(1 4 (9 16 (25 36 49)))

I think I’ll keep this in my utility toolkit. I am concerned about the performance, but I won’t worry too much about it until it becomes a problem.

Snow In Bay Area

So my first night in the Bay Area was relatively painless. The big story here is that it snowed in the valley areas. I guess it is not a common thing here, because the funniest thing was that news footage of some kids playing in a small patch of snow. I don’t know why it is funny to me, but those kids seem to enjoyed it. Given that there’s a snow storm brewing that is going to hit the Cleveland area when I fly in, I expect to be delayed.

Travelling Light

I’m getting ready to fly to San Francisco tomorrow on business. This- will be my first flight since January 2004 when my wife and I went to Las Vegas. Some recent changes to “airline policy” will irk me. For instance, the airlines started to charge for luggage, which I think is the most prominent example of nickel and diming your customers.

Since my trip is business, I am reimbursed, but it still sucks for someone. Luckily, I am only going to be in San Francisco for a few days, but it would be different if I was taking a trip for a vacation. If I was spending two weeks in California, I don’t think one bag would be enough. So, the thought of being charge $100 for luggage would literally drive me nuts.

Eh, so next time I travel for vacation, maybe I take a train.

Installed Kubuntu Today

For the longest time, I have always had a goal to be Windows-free. Many people I work with feel that it is pure apostasy, because I have worked in Microsoft shops in the past 10 years or so. But frankly, I am particularly sick of Windows as a whole. If I can still continue doing my work without having Windows on on my HP Pavillion dv9008nr laptop, then I think I am set.

So, I installed Kubuntu 9.04 (Juanty Jackalope) today. It was the most painless installation of Linux that I had… ever. It was even less painful that my initial installation of Ubuntu 8.10 (Intepid Ibex) on the family desktop (recently auto-updated to Jaunty).

My laptop wireless has the ever painful Broadcom chipset, which historically has been a problem on both 32-bit and 64-bit systems. But I found out that they got off their butts and started to provide drivers for Linux. So, after enabling the closed source drivers, my wireless just worked period. There was no manual configuration that I had to do, no driver to look for, and no searching through outdated documentation for clues on configuring everything.  Do you have any idea how refreshing that is?

Here are other refreshing things:

  • The NVidia chipset for graphics acceleration worked with zero configuration.
  • All of my external devices worked.
  • Even though I like the GNOME interface in Ubuntu, I absolutely love the KDE interface in Kubuntu.  I am ecstatic that I went in that direction.
  • BZFlag looks / feels much better on Linux that on Windows.
  • The best system for tools I already use on Windows: Pidgin, GNU Emacs, Steel Bank Common Lisp, Mozilla Firefox, and others.
  • Even Adobe Flash has decent performance, even though there is no 64-bit native version for Linux. Most YouTube videos do work, even in full screen mode. So, I can deal with it for now.  (Adobe is now the new Broadcom, IMO).
  • The default Remote Desktop (RDP) client allows me to connect to my Windows desktop at work, basically completing my minimum requirements for total conversion.

So, I look forward to writing more about my experiences on Kubuntu.

Groovy Baby, Yeah!

groovybabyWorking in mostly M$ shops in the past 10 years or so, coupled with my home projects in the functional languages, I don’t get to do much with Java or the JVM anymore.  But today, it was treated to my first experience in programming in Groovy.  The tool that I use to test SOAP web services, SoapUI, is built upon Java and uses the Groovy as embedded scripting language to manipulate the testing environment.

I must say that it is a pretty neat.  Just using it as a scripting language seem to be natural, almost like Python or Ruby. Even though I did not use any advanced features such as closures, builders, or regular expressions, I hope that I can give it a try some time.

Teagan’s Surgery


This is Teagan getting ready for his preoperative check-up.



Teagan is having surgery today.  You can follow his status here. Good luck, my son, and get well soon.

Google Maps: Superman in Metropolis

Last year, I was visiting my brother and his family in Paducah, KY.  While visiting, I heard that there was a statue of Superman in Metropolis.  Metropolis is just across the river in Illinois, but I decided to check out the Harrah’s Riverboat casino instead of visiting the statue. Thanks to Google Maps, I can see it for the first time.

April Fools Day: Aluminum Foil Cubicle

Well, this year for April Fool’s day, I decided to pull the classic cubicle prank. I (with the help of others) wallpapered a collegue’s cube in aluminum foil.

It’s not like it was an original prank, but I think I wanted to try it once. I honestly do not know how he would react, so I may die tomorrow. At least I’ll die on my terms.


Hey, it's nice and shiny!

Hey, it's nice and shiny!

Personally, it took longer than I expected, too.  It’s hard to get every detail correct without ripping the foil.  The original idea had us wrapping the flat panel monitors, but I thought it may be a fire hazard, so we left them alone. The black on silver provided a good contrast, no?

We are a stickler for detail. Each one of the pens and pencils in that cup are individually wrapped.  Attention to detail is important.  We honestly though that the prank would have sucked if we did not wrap the writing utensils and other items on the desk itself.

Attention to detail is quite important.

Attention to detail is quite important!

Real World Haskell

I received by copy of Real World Haskell yesterday from Amazon.  The book is thicker that I thought, which makes me think that it should have been made a hardcover.  But, I’ll just need to be careful, I guess.  

In the past 24 hours or so, I was able to read up to the fifth chapter on writing a Haskell library.  Even though that I read the draft of the book and seen people make comments, I am surprised that there are a few typographical errors in the few chapters that I read so far.  But, that should not distract anyone.  

It’s not like I have not programmed in Haskell before, but I wanted to see the hype behind this book myself. The book is an interesting read. In fact, I learn something new about the language that I did not know before I seen the book.  Looks like I am going to enjoy this!

Reading Programming Erlang

A few weeks ago, I received my copy of Joe Armstrong’s Programming Erlang: Software for a Concurrent World.  I was quite impressed.  It was a great introduction on the Erlang programming language and more importantly, concurrent programming. After reading the book, I am not sure if I fully understand it’s true power.  

What do I mean? The idea of having a language that is built for fault-tolerant, distributed, concurrent, mostly real-time applications may come as a pipe dream to some. To me, Erlang is the real deal. It’s simplified view of concurrency makes it easy to create high performance systems.  It’s share-nothing attitude toward memory and communication allows for high process scalability.  The simple fact that Erlang is a functional language allows these two concepts to exist.

There is just no equal in mainstream languages. Some may think that it was designed at some University and it’s nothing but a toy language.  The truth is that Erlang was created by a real company, by career engineers, to solve real world concurrent problems, and used in real products. So, one cannot really use that argument anymore.

 As recommended by the author, I have to read the book again and again.  I hope that I am able to read it again before I receive Real World Haskell in a few weeks.