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
13 October 2007 | 7 Comments
Update Due to minor demand, the code is also available: BigNum source. Please note that I haven’t actually touched the code since it was first written. I’m sure there’s some things that don’t work properly. If you’re doing anything big with this you probably want to write some ‘destructive’ update functions for adding, etc. At [...]
Tagged in .net, C#, Development, Programming, Work
Uncategorized
9 October 2007 | 1 Comment
Looking through the list of predefined (or, in Microsoft’s parlance, standard) query operators defined in C# 3.0, there is one that stands out as missing: the ‘map’ function. However, with the new query expression syntax, this is trivial to define: public static IEnumerable<T> Map<F,T>(Func<F,T> func, IEnumerable<F> source) { return from it in source select func(it); [...]
Tagged in C#, Cool, Development, Functional programming, LINQ, Programming
Uncategorized
28 September 2007 | 0 Comments
I had the thought—while browsing through some old code—that the code I used to implement futures in C# would be useful for doing things lazily, if you just moved the evaluation phase to when the value was actually demanded… this started me off thinking about how to implement a proper lazily-evaluated list in C#. A [...]
Tagged in C#, Cool, Development, Functional programming, Programming