Reversing a Linked List

Linked lists are an important data structure and also a popular source of interview questions. Few programmers will actually have to do a fully fledged linked list since most programming languages come with an implementation of it (usually of doubly linked lists). Nonetheless, understanding linked lists and other data structure will help you better understand runtime consequences of choosing one data structure over another. Reversing a linked list is a common task. »

The Visitor Pattern in Differen Languages

In this post I want to explore the usage of the visitor pattern in different programming languages. The goal is always to represent expression trees, i.e., to have the abstract syntax tree (AST) of an algebraic expression like 2 * 5 - 3. Let us start with a simple implementation in Java: import java.util.HashMap; import java.util.Map; public class ExpressionTree { public static interface Operator { int eval(int ... args); } public static Map<String, Operator> OPERATOR_MAP = new HashMap<String, Operator>(); static { OPERATOR_MAP. »

Character Encoding --- Part 2: HTTP Auth

My last blog entry was about the character encoding problems I had with Klatschbase. Of course, there has to be a follow-up, since encoding problems are so ubiquitous. I did a change to hunchentoot’s basic authorization method to allow utf-8 login name and password. As Edi Weitz pointed out in the hunchentoot mailinglist, this change is not standard compliant. Thinking about it, my assumptions were quite stupid. Why should the header, that is sent by the client, care about the standard encoding of the server. »

Character Encoding --- a Never Ending Story

Character encoding really is a never ending story. I am a huge fan of Unicode and UTF-8. But it is still not the default everywhere. This blog entry is about the problems I encountered while making Klatschbase working correctly with UTF-8. First of all, SBCL - my common lisp implementation of choice - supports UTF-8 out of the box. So, no problem here. Hunchentoot, Edi Weitz’s wonderful http server, supports UTF-8, but per default uses ISO-8859-1. »