code
10 May 2011 | 3 Comments
Today, thanks to user Lucero on StackOverflow, I learned about .NET’s “Balancing Groups” Regex feature. Basically, any time you use a named capturing group, it actually pushes the capture onto a named stack. You can then pop this stack by using the same capturing group prefixed with a hyphen, like (?< -stackToPop>). Of course, anyone [...]
Tagged in C, code, horrid, regex, silly, snippet, XML
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 Broken, code, criticism, Programming, Unicode
code
23 February 2011 | 0 Comments
Here’s a little example of statically-sized stacks in C#. They’re implemented with a linked-list as the backing store: using System; namespace ConsoleApplication { public static class MainClass { // Example: public static void Main(string[] args) { var stack = Stack.New<int>(); // real type Stack<Z,int> var s1 = stack.Push(1).Push(2).Push(3); // real type Stack<S<S<S<Z>>>> [...]
Tagged in C#, code, Development, silly, snippet
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 comparison, Functional programming, Haskell, Programming, quicksort, sorting