I have this sample code in C # that outputs an index and a value from an array:
static void Sample_Select_Lambda_Indexed()
{
string[] arr = { "my", "three", "words" };
var res = arr.Select((a, i) => new
{
Index = i,
Val = a
});
foreach(var element in res)
Console.WriteLine(String.Format("{0}: {1}", element.Index, element.Val));
}
Output:
0: my
1: three
2: words
I want to make a similar request in F # and started like this:
let arr = [|"my"; "three"; "words"|]
let res = query {
for a in arr do
// ???
}
How do I end this LINQ query?
source
share