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….


NotImplementedException vs. NotSupportedException

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…


Extension Methods and ByRef targets

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. …


Immutable Collections and Compatibility with Existing Frameworks

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…


Mapping LINQ to F#

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…


Sorting out Binary Files

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…


Comparing Continuations in C# and F# Part 3: Double wrong

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…


Comparing Continuations in C# and F# Part 2

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…


Properly Incrementing an IntPtr

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…


Comparing Continuations in F# and C#

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…