Year: 2008

With all of the great built-in commands for processing pipelines the absence of a good command to count the number of elements in a pipeline seems to stand out. The best built-in way to count the number of objects in a pipeline is to convert the value into an array and then take the length….

In responding to a recent blog post, one of the readers, Jeremy Gray, noted that I was using a NotImplementedException where I should have been using a NotSupportedException. At first I did not agree. There was a method on an interface which my underlying object could not implement therefore I felt the choice of NotImplementedException…

One of the seldom used, and often unknown, features of VB extension methods is that the argument of the extension method (the first parameter) can be passed by reference. This gives extension methods the power to change the reference that was used to invoke the value! Obviously this can produce unexpected but often amusing behavior. …

When developing my immutable collections library, I spent a lot of time on usability. After all, if a library is not useful then what’s the point? A big portion of usability is being able to work with existing frameworks and technologies. For .Net and collections that means items like Data binding, LINQ etc … Without…

In my projects with F#, I often find that I know exactly what type of sequence transformation I want to run, yet I spend all of my time trying to find it!!! The problem is I’m used to query comprehensions in LINQ terminology. Select, Where and SelectMany are so ingrained into my programming they are…

I constantly get tripped up in my powershell scripts/commands because I run them against a binary file. In particular when I’m searching through a directory structure looking for a particular string or regex. I’ve found the simplest way to avoid this problem is to use a simple regex check to filter out the known binary…

Is it better to be wrong once or to be right then think you’re wrong but find out you were right but wrong about being wrong? Besides the obvious be right the first time, it’s certainly an educational experience. Here’s the original sample: let FoldRight combine (sequence:seq<‘a>) acc = use e = sequence.GetEnumerator() let rec…

In my last post I went over the differences between using a continuation in F# and C#. As it turns out I was right about the limits and symptoms but wrong about the reason. The F# code does indeed generate tail calls for part of the continuation. However this is only a very small portion…

Just as native pointer types are moved around with pointer arithmetic in native code, it can also be useful to move IntPtr types around in managed code. Say for instance there is an IntPtr available which points to a native array of Dog instances. To access the values of that array individually requires pointer arithmetic…

Lately I’ve been playing quite a bit with F#. I have several hobby projects I’m working on that take up a bit of my time. But when I’m not playing around with F# I’m exploring ways to apply certain functional patterns to actual coding on the job and/or porting to my functional library: RantPack. Recently…