Esempio n. 1
0
    public static void MapOne()
    {
        // define a list of names
        List <string> names = new List <string>(
            new string[] { "Stefany", "Oussama",
                           "Sebastien", "Frederik" });

        // define a predicate delegate/function
        Converter <string, bool> pred =
            delegate(string s) { return(s.StartsWith("S")); };

        // convert to a FastFunc
        FSharpFunc <string, bool> ff =
            FuncConvert.ToFSharpFunc <string, bool>(pred);

        // call the F# demo function
        IEnumerable <string> results =
            DemoModule2.filterStringList(ff, names);

        // write the results to the console
        foreach (var name in results)
        {
            Console.WriteLine(name);
        }
    }
Esempio n. 2
0
    public static void MapTwo()
    {
        // define a list of names
        List <string> names = new List <string>(
            new string[] { "Aurelie", "Fabrice",
                           "Ibrahima", "Lionel" });

        // call the F# demo function passing in an
        // anonymous delegate
        List <string> results =
            DemoModule2.filterStringListDelegate(
                delegate(string s) { return(s.StartsWith("A")); }, names);

        // write the results to the console
        foreach (var s in results)
        {
            Console.WriteLine(s);
        }
    }