Casting in .NET via object mutation

code 13 May 2011 | 0 Comments

In this post, we will see how to make the following code fail: object it = new SomeStruct { Item = 1 };   Floatsy(it);   Console.WriteLine(((SomeStruct)it).Item); At runtime, it will throw an InvalidCastException!

Tagged in , , , ,

Validating email addresses with .NET regex

code 10 May 2011 | 0 Comments

I did validation in Haskell a while back, and since I recently discovered .NET’s “balancing groups” regex feature, it seems like it would be a good time to do it for .NET.

Tagged in , , , ,

Unicode as she is broke

code 14 March 2011 | 0 Comments

Do you think your string-handling code is robust? Are there any problems with the following snippets?

Tagged in , , , ,

n-pivot quicksort

code 12 September 2009 | 1 Comment

2-pivot quicksort This posting on the Java core library mailing list proposes to replace the current quicksort with a new, 2-pivot quicksort. Ordinary quicksort in Haskell looks something like this: quicksort [] = [] quicksort (pivot:rest) = quicksort [x| x ← rest, x ≤ pivot] ++ [pivot] ++ quicksort [x| x ← rest, x > [...]

Tagged in , , , , ,