Pages

Sunday, November 28, 2010

Default Company name for Visual Studio 2010 project

you have to change:


  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\RegisteredOrganization (for 32-bit version)
  • HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\RegisteredOrganization (for Windows 7 64-bit)
I tested it on Win7 version.

Monday, November 8, 2010

F# continuation

Another sample of F# continuation passing style (CPS).

let F01 list =
            let rec FF list cont =
                match list with
                    | [] -> cont(0)
                    | h::t -> FF t (fun x -> cont(h+x))
            FF list (fun x-> x)

Friday, November 5, 2010

F# interop with C#

In F# file:

namespace AA

    [ < system.runtime.compilerservices.extension > ]
    module BB =
        [< system.runtime.compilerservices.extension > 
        let F(i:System.Int32, first:char, last:char) = {first .. last}

        let F2(a,b) = 12

In C#, you can call:


            int a = 3;
            var list = a.F('a', 'z');
            var b = BB.F2(a, 0.5);

Thursday, November 4, 2010

Serialization when using Base class

XmlInclude is the key, it should put on the base class and make the serialization of Automobile feasible.

[System.Xml.Serialization.XmlInclude(typeof(Car))]
[System.Xml.Serialization.XmlInclude(typeof(Truck))]
public class Automobile
{
    public string Name;
    public int Year;
}

public class Car : Automobile
{
    public int NumerOfDoors;
}

public class Truck : Automobile
{
    public bool LongBed;
}

Monday, November 1, 2010

Recursion in F# Yacc

Just do not know why, keep forget the recursion for fsyacc.


List:
| Expr { [$1] }
| List ',' Expr { $3::$1 }