Contents tagged with C#
-
F#, the ACM, and the SEC
It all started with a twit from @mulambda: “Phil Wadler lists #fsharp as a candidate for SEC regulation spec language: http://tinyurl.com/2edfxka” I downloaded the, nonetheless, Association for Computer Machinery answer to the Securities and Exchange Commission proposal (and ask for comments) on requiring Python programs to be provided to explain contractual cash flow provisions. I quickly skimmed the ACM document and twitted “Java, C#, and F# recommended by the #ACM for SEC regulation spec language http://is.gd/e49Vt #fsharp /via @mulambda”. Later, I read with more care the ACM answer and I found that I really should clarify my twit:
-
A quick and dirty implementation of Excel NORMINV function in C#
We are piloting the implementation of some financial risk models in F#, it so happens that the models are already implemented in Excel, so I was slowly digging out the formulas in the cells and translating them to F#. Everything was going fine until I found out that some formulas used the NORMINV function which doesn't exist in the .NET libraries. I started to look for F#, and then C#, implementations without luck (as we are just in the lets-see-if-this-have-any-chance-of-flying stage, we can’t afford any of the excellent but paid numerical libraries for .NET). The closest thing I found was a C++ implementation. The code looked really weird to me (my fault, not the coder's), so I decided to do the translation in two steps: first from C++ to C#, then on to F#. The C# translation seems to be working now, and you can download it from SkyDrive:
-
Visual Studio 2010 and .NET Framework Beta 2 available on Wednesday
This blog has been abandoned for the longest time :-$ but I’ve got great news to try and re-inaugurate it (again): it’s just been announced that beta 2 for Visual Studio 2010 and .NET Framework 4 will be available the day after tomorrow, i.e. on October 21st; moreover, we now have a firm date for the launch of the final versions of these products: March 22nd 2010. There is a lot of cool stuff in the new versions of Visual Studio and .NET Framework but my personal favorites (at least for the time being :-) are:
-
Cloning objects in .NET
In an interesting project where I'm giving a hand, we need to clone objects of a number of different types, perhaps surprisingly the CLR doesn't offer a general cloning method, of course you could use MemberwiseClone() but this is a protected method, so it can be invoked only from inside the class of the object being cloned, which makes it difficult to use it in a general method, besides, MemberWiseClone() does just a shallow copy and what we really need is a deep copy.
-
A cool way to find out whether a number is palindromic
In this blog entry I proposed a solution to Problem 4 at Project Euler, a crucial element of the problem is to find out whether a number is a palindrome (909 is, 809 isn't), a bit out of laziness and a bit in order to reuse existing methods, I decided to verify the palindrome by converting the number into a char array and then comparing this array with its mirror version, it works but it's not really that mathematical... Dustin Campbell proposed a solution kind of similar to mine (alas, more elegant and, above that, in F#) and using the same trick of converting the number to chars, as he didn't like this part of the solution, in this new blog entry he proposes the detection of a palindrome by mirroring the number one digit at a time. A translation of his F# code to C# 3.0 could be:
-
Which is the ten thousand first prime?
Prime numbers have a good deal of practical applications (for example in cryptography) but let's face it, even if they would have none, they would still be the favorite toy of mathematicians. In Problem 7 of Project Euler, we are asked to find the 10001st element of the famous list, my approach was this:
-
The square of the sum vs. the sum of the squares
The sixth Project Euler problem poses an exercise that, to me, offers no major hurdles:
-
Recursive lambdas and sequence aggregations
The fifth problem at Project Euler proposes this nostalgic primary school exercise: find the smallest quantity that is evenly divisible by some numbers, the least common multiple of 1, 2, 3, ..., 20 to be precise. To begin with, let's remember the old arithmetic formula:
-
Nested sequences and palindrome numbers
Problem 4 of Project Euler poses and impractical albeit intriguing problem: given all three digit numbers (100, 101, 102, ..., 998, 999), find the largest product of 2 of those numbers, where the product is a palindrome. For example, 580.085 is the product of two three-digit numbers (995 x 583) but it isn't the largest of such products. One possible functional C# solution is:
-
Oracle 10g for Windows Vista released