From 4ec3280b502f3b31354150966e64be9bb4ddb823 Mon Sep 17 00:00:00 2001 From: albert-du <52804499+albert-du@users.noreply.github.com> Date: Wed, 20 Apr 2022 20:37:12 -0700 Subject: [PATCH] Tuple F# snippet --- .../TupleT1,T2,T3,T4,T5,T6/Equals/equals1.fs | 31 +++++++ .../TupleT1,T2,T3,T4,T5,T6/Equals/equals2.fs | 41 ++++++++++ .../TupleT1,T2,T3,T4,T5,T6/Equals/fs.fsproj | 11 +++ .../TupleT1,T2,T3,T4,T5,T6/Item1/fs.fsproj | 10 +++ .../TupleT1,T2,T3,T4,T5,T6/Item1/item1.fs | 25 ++++++ .../Overview/example1.fs | 36 +++++++++ .../TupleT1,T2,T3,T4,T5,T6/Overview/fs.fsproj | 10 +++ .../compareto1.fs | 36 +++++++++ .../compareto2.fs | 81 +++++++++++++++++++ .../fs.fsproj | 11 +++ .../TupleT1,T2,T3,T4,T5,T6/ToString/fs.fsproj | 10 +++ .../ToString/tostring1.fs | 9 +++ xml/System/Tuple`6.xml | 14 ++++ 13 files changed, 325 insertions(+) create mode 100644 snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Equals/equals1.fs create mode 100644 snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Equals/equals2.fs create mode 100644 snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Equals/fs.fsproj create mode 100644 snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/fs.fsproj create mode 100644 snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/item1.fs create mode 100644 snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Overview/example1.fs create mode 100644 snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Overview/fs.fsproj create mode 100644 snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/System.Collections.IStructuralComparable.CompareTo/compareto1.fs create mode 100644 snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/System.Collections.IStructuralComparable.CompareTo/compareto2.fs create mode 100644 snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/System.Collections.IStructuralComparable.CompareTo/fs.fsproj create mode 100644 snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/ToString/fs.fsproj create mode 100644 snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/ToString/tostring1.fs diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Equals/equals1.fs b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Equals/equals1.fs new file mode 100644 index 00000000000..26460796e4a --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Equals/equals1.fs @@ -0,0 +1,31 @@ +module equals1 + +// +open System + +// Get population data for New York City and Los Angeles, 1960-2000. +let urbanPopulations = + [| Tuple.Create("New York", 7781984, 7894862, 7071639, 7322564, 8008278) + Tuple.Create("Los Angeles", 2479015, 2816061, 2966850, 3485398, 3694820) + Tuple.Create("New York City", 7781984, 7894862, 7071639, 7322564, 8008278) + Tuple.Create("New York", 7781984, 7894862, 7071639, 7322564, 8008278) |] +// Compare each tuple with every other tuple for equality. +for ctr = 0 to urbanPopulations.Length - 2 do + let urbanPopulation = urbanPopulations[ctr] + printfn $"{urbanPopulation} = " + for innerCtr = ctr + 1 to urbanPopulations.Length - 1 do + printfn $" {urbanPopulations[innerCtr]}: {urbanPopulation.Equals urbanPopulations[innerCtr]}" + printfn "" +// The example displays the following output: +// (New York, 7781984, 7894862, 7071639, 7322564, 8008278) = +// (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820): False +// (New York City, 7781984, 7894862, 7071639, 7322564, 8008278): False +// (New York, 7781984, 7894862, 7071639, 7322564, 8008278): True +// +// (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820) = +// (New York City, 7781984, 7894862, 7071639, 7322564, 8008278): False +// (New York, 7781984, 7894862, 7071639, 7322564, 8008278): False +// +// (New York City, 7781984, 7894862, 7071639, 7322564, 8008278) = +// (New York, 7781984, 7894862, 7071639, 7322564, 8008278): False +// \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Equals/equals2.fs b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Equals/equals2.fs new file mode 100644 index 00000000000..0aebd7c0a2d --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Equals/equals2.fs @@ -0,0 +1,41 @@ +// +open System +open System.Collections + +type RateComparer<'T1, 'T2, 'T3, 'T4, 'T5, 'T6>() = + let mutable argument = 0 + + interface IEqualityComparer with + member _.Equals(x, y) = + argument <- argument + 1 + if argument = 1 then true + else + match x with + | :? double as fx -> + let fy = y :?> double + Math.Round(fx * 1000.).Equals(Math.Round(fy * 1000.)) + | _ -> + x.Equals y + + member _.GetHashCode(obj) = + if obj :? Single || obj :? Double then + Math.Round((obj :?> double) * 1000.).GetHashCode() + else + obj.GetHashCode() + +let rate1 = Tuple.Create("New York", 0.014505, -0.1042733, 0.0354833, 0.093644, 0.0290792) +let rate2 = Tuple.Create("Unknown City", 0.014505, -0.1042733, 0.0354833, 0.093644, 0.0290792) +let rate3 = Tuple.Create("Unknown City", 0.014505, -0.1042733, 0.0354833, 0.093644, 0.029079) +let rate4 = Tuple.Create("San Francisco", -0.0332858, -0.0512803, 0.0662544, 0.0728964, 0.0491912) +let eq: IStructuralEquatable = rate1 +// Compare first tuple with remaining two tuples. +printfn $"{rate1} = " +printfn $" {rate2} : {eq.Equals(rate2, RateComparer())}" +printfn $" {rate3} : {eq.Equals(rate3, RateComparer())}" +printfn $" {rate4} : {eq.Equals(rate4, RateComparer())}" +// The example displays the following output: +// (New York, 0.014505, -0.1042733, 0.0354833, 0.093644, 0.0290792) = +// (Unknown City, 0.014505, -0.1042733, 0.0354833, 0.093644, 0.0290792) : True +// (Unknown City, 0.014505, -0.1042733, 0.0354833, 0.093644, 0.029079) : True +// (San Francisco, -0.0332858, -0.0512803, 0.0662544, 0.0728964, 0.0491912) : False +// \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Equals/fs.fsproj b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Equals/fs.fsproj new file mode 100644 index 00000000000..dffbaeb281d --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Equals/fs.fsproj @@ -0,0 +1,11 @@ + + + Exe + net6.0 + + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/fs.fsproj b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/fs.fsproj new file mode 100644 index 00000000000..2180baba850 --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/item1.fs b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/item1.fs new file mode 100644 index 00000000000..f633c5deb38 --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/item1.fs @@ -0,0 +1,25 @@ +// +open System + +// Create tuples containing population data for New York, Chicago, +// and Los Angeles, 1960-2000. +let cities = + [| Tuple.Create("New York", 7781984, 7894862, 7071639, 7322564, 8008278) + Tuple.Create("Los Angeles", 2479015, 2816061, 2966850, 3485398, 3694820) + Tuple.Create("Chicago", 3550904, 3366957, 3005072, 2783726, 2896016) |] + +// Display tuple data in table. +let header = "Population in" +printfn $"""{"City",-12} {String('-',(60 - header.Length) / 2) + header + String('-', (60 - header.Length) / 2),60}""" +printfn "%25s%12s%12s%12s%12s\n" "1960" "1970" "1980" "1990" "2000" + +for city in cities do + printfn $"{city.Item1,-12} {city.Item2,12:N0}{city.Item3,12:N0}{city.Item4,12:N0}{city.Item5,12:N0}{city.Item6,12:N0}" +// The example displays the following output: +// City -----------------------Population in----------------------- +// 1960 1970 1980 1990 2000 +// +// New York 7,781,984 7,894,862 7,071,639 7,322,564 8,008,278 +// Los Angeles 2,479,015 2,816,061 2,966,850 3,485,398 3,694,820 +// Chicago 3,550,904 3,366,957 3,005,072 2,783,726 2,896,016 +// \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Overview/example1.fs b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Overview/example1.fs new file mode 100644 index 00000000000..dd13e61321d --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Overview/example1.fs @@ -0,0 +1,36 @@ +// +open System + +let computePopulationChange (data: Tuple) = + Tuple.Create(data.Item1, + double ((data.Item3 - data.Item2) / data.Item2), + double ((data.Item4 - data.Item3) / data.Item3), + double ((data.Item5 - data.Item4) / data.Item4), + double ((data.Item6 - data.Item5) / data.Item5), + double ((data.Item6 - data.Item2) / data.Item2)) + +// Get population data for New York City, 1960-2000. +let population = + Tuple.Create("New York", 7781984, 7894862, 7071639, 7322564, 8008278) +let rate = computePopulationChange population +// Display results. +printfn $"Population Change, {population.Item1}, 1960-2000\n" +printfn $"""Year {"Population",10} {"Annual Rate",9}""" +printfn $"""1960 {population.Item2,10:N0} {"NA",11}""" +printfn $"1970 {population.Item3,10:N0} {rate.Item2 / 10.,11:P2}" +printfn $"1980 {population.Item4,10:N0} {rate.Item3 / 10.,11:P2}" +printfn $"1990 {population.Item5,10:N0} {rate.Item4 / 10.,11:P2}" +printfn $"2000 {population.Item6,10:N0} {rate.Item5 / 10.,11:P2}" +printfn $"""1960-2000 {"",10:N0} {rate.Item6 / 50.,11:P2}""" + +// The example displays the following output: +// Population Change, New York, 1960-2000 +// +// Year Population Annual Rate +// 1960 7,781,984 NA +// 1970 7,894,862 0.15 % +// 1980 7,071,639 -1.04 % +// 1990 7,322,564 0.35 % +// 2000 8,008,278 0.94 % +// 1960-2000 0.06 % +// \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Overview/fs.fsproj b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Overview/fs.fsproj new file mode 100644 index 00000000000..f6fb5493c80 --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Overview/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/System.Collections.IStructuralComparable.CompareTo/compareto1.fs b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/System.Collections.IStructuralComparable.CompareTo/compareto1.fs new file mode 100644 index 00000000000..07158c7a590 --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/System.Collections.IStructuralComparable.CompareTo/compareto1.fs @@ -0,0 +1,36 @@ +module compareto1 + +// +open System + +// Create array of sextuple with population data for three U.S. +// cities, 1960-2000. +let cities = + [| Tuple.Create("Los Angeles", 2479015, 2816061, 2966850, 3485398, 3694820) + Tuple.Create("New York", 7781984, 7894862, 7071639, 7322564, 8008278) + Tuple.Create("Chicago", 3550904, 3366957, 3005072, 2783726, 2896016) |] + +// Display array in unsorted order. +printfn "In unsorted order:" +for city in cities do + printfn $"{city}" + +printfn "" + +Array.Sort cities + +// Display array in sorted order. +printfn "In sorted order:" +for city in cities do + printfn $"{city}" +// The example displays the following output: +// In unsorted order: +// (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820) +// (New York, 7781984, 7894862, 7071639, 7322564, 8008278) +// (Chicago, 3550904, 3366957, 3005072, 2783726, 2896016) +// +// In sorted order: +// (Chicago, 3550904, 3366957, 3005072, 2783726, 2896016) +// (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820) +// (New York, 7781984, 7894862, 7071639, 7322564, 8008278) +// \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/System.Collections.IStructuralComparable.CompareTo/compareto2.fs b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/System.Collections.IStructuralComparable.CompareTo/compareto2.fs new file mode 100644 index 00000000000..b49af0fcc0f --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/System.Collections.IStructuralComparable.CompareTo/compareto2.fs @@ -0,0 +1,81 @@ +module compareto2 + +// +open System +open System.Collections +open System.Collections.Generic + +type PopulationComparer<'T1, 'T2, 'T3, 'T4, 'T5, 'T6>(comp, descending) = + let multiplier = if descending then -1 else 1 + + do + if comp <= 0 || comp > 6 then + invalidArg "comp" "The component argument is out of range." + + new (comp) = PopulationComparer(comp, true) + + interface IComparer with + member _.Compare(x, y) = + match x with + | :? Tuple<'T1, 'T2, 'T3, 'T4, 'T5, 'T6> as tX -> + let tY = y :?> Tuple<'T1, 'T2, 'T3, 'T4, 'T5, 'T6> + match comp with + | 1 -> + Comparer<'T1>.Default.Compare(tX.Item1, tY.Item1) * multiplier + | 2 -> + Comparer<'T2>.Default.Compare(tX.Item2, tY.Item2) * multiplier + | 3 -> + Comparer<'T3>.Default.Compare(tX.Item3, tY.Item3) * multiplier + | 4 -> + Comparer<'T4>.Default.Compare(tX.Item4, tY.Item4) * multiplier + | 5 -> + Comparer<'T5>.Default.Compare(tX.Item5, tY.Item5) * multiplier + | 6 -> + Comparer<'T6>.Default.Compare(tX.Item6, tY.Item6) * multiplier + | _ -> + Comparer<'T1>.Default.Compare(tX.Item1, tY.Item1) * multiplier + | _ -> 0 + +// Create array of sextuple with population data for three U.S. +// cities, 1960-2000. +let cities = + [| Tuple.Create("Los Angeles", 2479015, 2816061, 2966850, 3485398, 3694820) + Tuple.Create("New York", 7781984, 7894862, 7071639, 7322564, 8008278) + Tuple.Create("Chicago", 3550904, 3366957, 3005072, 2783726, 2896016) |] + +// Display array in unsorted order. +printfn "In unsorted order:" +for city in cities do + printfn $"{city}" +printfn "" + +Array.Sort(cities, PopulationComparer 3) + +// Display array in sorted order. +printfn "Sorted by population in 1970:" +for city in cities do + printfn $"{city}" +printfn "" + +Array.Sort(cities, PopulationComparer 6) + +// Display array in sorted order. +printfn "Sorted by population in 2000:" +for city in cities do + printfn $"{city}" +// The example displays the following output: +// In unsorted order: +// (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820) +// (New York, 7781984, 7894862, 7071639, 7322564, 8008278) +// (Chicago, 3550904, 3366957, 3005072, 2783726, 2896016) +// +// Sorted by population in 1970: +// (New York, 7781984, 7894862, 7071639, 7322564, 8008278) +// (Chicago, 3550904, 3366957, 3005072, 2783726, 2896016) +// (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820) +// +// Sorted by population in 2000: +// (New York, 7781984, 7894862, 7071639, 7322564, 8008278) +// (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820) +// (Chicago, 3550904, 3366957, 3005072, 2783726, 2896016) +// \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/System.Collections.IStructuralComparable.CompareTo/fs.fsproj b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/System.Collections.IStructuralComparable.CompareTo/fs.fsproj new file mode 100644 index 00000000000..d47d675ba4d --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/System.Collections.IStructuralComparable.CompareTo/fs.fsproj @@ -0,0 +1,11 @@ + + + Exe + net6.0 + + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/ToString/fs.fsproj b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/ToString/fs.fsproj new file mode 100644 index 00000000000..18e3d41d05a --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/ToString/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/ToString/tostring1.fs b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/ToString/tostring1.fs new file mode 100644 index 00000000000..7293f3a1375 --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/ToString/tostring1.fs @@ -0,0 +1,9 @@ +// +open System + +// Get population data for New York City, 1960-2000. +let population = Tuple.Create("New York", 7781984, 7894862, 7071639, 7322564, 8008278) +printfn $"{population.ToString()}" +// The example displays the following output: +// (New York, 7781984, 7894862, 7071639, 7322564, 8008278) +// \ No newline at end of file diff --git a/xml/System/Tuple`6.xml b/xml/System/Tuple`6.xml index 110d8c7feed..a15def9ce08 100644 --- a/xml/System/Tuple`6.xml +++ b/xml/System/Tuple`6.xml @@ -97,6 +97,7 @@ - To provide easy access to, and manipulation of, a data set. The following example defines a object that contains population data for New York City for each census from 1960 through 2000. The sextuple is passed to the `ComputePopulationChange` method, which calculates the annual rate of change between censuses, as well as the annual rate of change for the entire 50 year period. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5,T6/Overview/example1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Overview/example1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`6.class/vb/example1.vb" id="Snippet1"::: - To return multiple values from a method without the use of `out` parameters (in C#) or `ByRef` parameters (in Visual Basic). For example, the previous example returns its computed statistics, along with the city name, in a object. @@ -169,11 +170,13 @@ You can also use the static method to instantiate a 6-tuple object without having to explicitly specify the types of its components. The following example uses the method to instantiate a 6-tuple whose first component is of type and whose remaining components are of type . :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" id="Snippet11"::: + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet11"::: This is equivalent to the following call to the class constructor. :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" id="Snippet12"::: + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet12"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet12"::: ]]> @@ -248,6 +251,7 @@ The following example defines an array of sextuples that contain population data for Los Angeles and New York from 1960 to 2000. The first component of each sextuple identifies the city. The first, third, and fourth sextuples contain data for New York. The first sextuple is a duplicate of the fourth sextuple. The third sextuple identifies the city as "New York City" instead of "New York". As the example shows, only the fourth sextuple is equal to the first sextuple. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5,T6/Equals/equals1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Equals/equals1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`6.equals/vb/equals1.vb" id="Snippet1"::: ]]> @@ -348,6 +352,7 @@ The following example defines an array of objects whose components contain population data for three U.S. cities (New York, Chicago, and Los Angeles) from 1960 through 2000. It then displays a table that lists the data. To display the city name, it retrieves the value of the property for each object. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/item1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/item1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`6.item1/vb/item1.vb" id="Snippet1"::: ]]> @@ -407,6 +412,7 @@ The following example defines an array of objects whose components contain population data for three U.S. cities (New York, Chicago, and Los Angeles) from 1960 through 2000. It then displays a table that lists the data. To display the population in 1960, it retrieves the value of the property for each object. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/item1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/item1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`6.item1/vb/item1.vb" id="Snippet1"::: ]]> @@ -466,6 +472,7 @@ The following example defines an array of objects whose components contain population data for three U.S. cities (New York, Chicago, and Los Angeles) from 1960 through 2000. It then displays a table that lists the data. To display the population in 1970, it retrieves the value of the property for each object. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/item1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/item1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`6.item1/vb/item1.vb" id="Snippet1"::: ]]> @@ -525,6 +532,7 @@ The following example defines an array of objects whose components contain population data for three U.S. cities (New York, Chicago, and Los Angeles) from 1960 through 2000. It then displays a table that lists the data. To display the population in 1980, it retrieves the value of the property for each object. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/item1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/item1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`6.item1/vb/item1.vb" id="Snippet1"::: ]]> @@ -584,6 +592,7 @@ The following example defines an array of objects whose components contain population data for three U.S. cities (New York, Chicago, and Los Angeles) from 1960 through 2000. It then displays a table that lists the data. To display the population in 1990, it retrieves the value of the property for each object. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/item1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/item1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`6.item1/vb/item1.vb" id="Snippet1"::: ]]> @@ -643,6 +652,7 @@ The following example defines an array of objects whose components contain population data for three U.S. cities (New York, Chicago, and Los Angeles) from 1960 through 2000. It then displays a table that lists the data. To display the population in 2000, it retrieves the value of the property for each object. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/item1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Item1/item1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`6.item1/vb/item1.vb" id="Snippet1"::: ]]> @@ -736,6 +746,7 @@ The example then displays the elements in the array in unsorted order, sorts them by the third component (the population in 1970) and displays them, and then sorts them by the sixth component (the population in 2000) and displays them. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5,T6/System.Collections.IStructuralComparable.CompareTo/compareto2.cs" id="Snippet2"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/System.Collections.IStructuralComparable.CompareTo/compareto2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`6.compareto/vb/compareto2.vb" id="Snippet2"::: ]]> @@ -812,6 +823,7 @@ The following example defines a `RateComparer` class that performs a custom test for equality. If the values that are passed to its method are of type or , the method tests for equality by using only up to three fractional digits. Otherwise, it simply calls the `x` parameter's `Equals` method. The example uses this implementation to determine whether four objects that contain data on the rate of population change between 1960 and 2000 are equal. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5,T6/Equals/equals2.cs" interactive="try-dotnet" id="Snippet2"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/Equals/equals2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`6.equals/vb/equals2.vb" id="Snippet2"::: ]]> @@ -957,6 +969,7 @@ The following example creates an array of objects that contain population data for three cities in the United States from 1960 to 2000. The six components consist of the city name followed by the city's population at 10-year intervals from 1960 to 2000. The example displays the components of each tuple in the array in unsorted order, sorts the array, and then calls the method to display each tuple in sorted order. The output shows that the array has been sorted by name, which is the first component. Note that the example does not directly call the method. This method is called implicitly by the method for each element in the array. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5,T6/System.Collections.IStructuralComparable.CompareTo/compareto1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/System.Collections.IStructuralComparable.CompareTo/compareto1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`6.compareto/vb/compareto1.vb" id="Snippet1"::: ]]> @@ -1110,6 +1123,7 @@ The following example defines a object that contains population data for New York City for each census from 1960 through 2000. The components of the sextuple are then displayed by a call to the method. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5,T6/ToString/tostring1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5,T6/ToString/tostring1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`6.tostring/vb/tostring1.vb" id="Snippet1"::: ]]>