Skip to content

Commit 3d9ff62

Browse files
Merge branch 'master' of https://github.com/Microsoft/VisualFSharp into csharp-optional-param-compat
2 parents d76cf30 + 2c9935c commit 3d9ff62

File tree

5 files changed

+35
-17
lines changed

5 files changed

+35
-17
lines changed

src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ListModule.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,6 @@ type ListModule() =
10241024
member this.``pairwise should return pairs of the input list``() =
10251025
Assert.AreEqual(([] : (obj*obj) list), List.pairwise [])
10261026
Assert.AreEqual(([] : (int*int) list), List.pairwise [1])
1027-
Assert.AreEqual([1,2],List.pairwise [1;2])
1028-
Assert.AreEqual([1,2; 2,3],List.pairwise [1;2;3])
1029-
Assert.AreEqual(["H","E"; "E","L"; "L","L"; "L","O"],List.pairwise ["H";"E";"L";"L";"O"])
1027+
Assert.AreEqual([1,2], List.pairwise [1;2])
1028+
Assert.AreEqual([1,2; 2,3], List.pairwise [1;2;3])
1029+
Assert.AreEqual(["H","E"; "E","L"; "L","L"; "L","O"], List.pairwise ["H";"E";"L";"L";"O"])

src/fsharp/FSharp.Core/list.fs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,7 @@ namespace Microsoft.FSharp.Collections
223223

224224
[<CompiledName("Pairwise")>]
225225
let pairwise (list: 'T list) =
226-
let array = List.toArray list
227-
if array.Length < 2 then [] else
228-
List.init (array.Length-1) (fun i -> array.[i],array.[i+1])
229-
226+
Microsoft.FSharp.Primitives.Basics.List.pairwise list
230227

231228
[<CompiledName("Reduce")>]
232229
let reduce f list =

src/fsharp/FSharp.Core/local.fs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@ module internal List =
8484
cons <- cons2
8585
setFreshConsTail cons []
8686
res
87+
88+
let rec pairwiseToFreshConsTail cons list lastvalue =
89+
match list with
90+
| [] -> setFreshConsTail cons []
91+
| [h] -> setFreshConsTail cons [(lastvalue, h)]
92+
| h::t ->
93+
let cons2 = freshConsNoTail (lastvalue, h)
94+
setFreshConsTail cons cons2
95+
pairwiseToFreshConsTail cons2 t h
96+
97+
let pairwise list =
98+
match list with
99+
| [] -> []
100+
| [_] -> []
101+
| x1::x2::t ->
102+
let cons = freshConsNoTail (x1, x2)
103+
pairwiseToFreshConsTail cons t x2
104+
cons
87105

88106
let rec chooseToFreshConsTail cons f xs =
89107
match xs with

src/fsharp/FSharp.Core/local.fsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module internal List =
1010
val allPairs : 'T1 list -> 'T2 list -> ('T1 * 'T2) list
1111
val choose: ('T -> 'U option) -> 'T list -> 'U list
1212
val countBy : System.Collections.Generic.Dictionary<'T1, int> -> ('T1 -> 'T2) -> ('T2 * int) list
13+
val pairwise : 'T list -> ('T * 'T) list
1314
val distinctWithComparer : System.Collections.Generic.IEqualityComparer<'T> -> 'T list -> 'T list
1415
val distinctByWithComparer : System.Collections.Generic.IEqualityComparer<'Key> -> ('T -> 'Key) -> list:'T list -> 'T list when 'Key : equality
1516
val init : int -> (int -> 'T) -> 'T list

vsintegration/tests/unittests/Tests.LanguageService.Script.fs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -570,14 +570,24 @@ type UsingMSBuild() as this =
570570
[<Test>]
571571
[<Category("fsx closure")>]
572572

573-
// 'Microsoft.VisualStudio.Shell.15.0.dll' is resolved via AssemblyFoldersEx over recent VS releases
573+
// 'Microsoft.VisualStudio.QualityTools.Common.dll' is resolved via AssemblyFoldersEx over recent VS releases
574574
member public this.``Fsx.NoError.HashR.ResolveFromAssemblyFoldersEx``() =
575575
let fileContent = """
576576
#light
577-
#r "Microsoft.VisualStudio.Shell.15.0.dll"
577+
#r "Microsoft.VisualStudio.QualityTools.Common.dll"
578578
"""
579579
this.VerifyFSXNoErrorList(fileContent)
580580

581+
[<Test>]
582+
[<Category("fsx closure")>]
583+
// Can be any assembly that is in AssemblyFolders but not AssemblyFoldersEx
584+
member public this.``Fsx.NoError.HashR.ResolveFromAssemblyFolders``() =
585+
let fileContent = """
586+
#light
587+
#r "Microsoft.SqlServer.SString"
588+
"""
589+
this.VerifyFSXNoErrorList(fileContent)
590+
581591
[<Test>]
582592
[<Category("fsx closure")>]
583593
member public this.``Fsx.NoError.HashR.ResolveFromFullyQualifiedPath``() =
@@ -967,14 +977,6 @@ type UsingMSBuild() as this =
967977
"""#r "mscorcfg" """ // 'mscorcfg' is loaded from the GAC _and_ it is available on XP and above.
968978
"#r \"mscor" "Global Assembly Cache"
969979

970-
// as it used to be.
971-
[<Test;Category("fsx closure"); Category("NO_CI")>]
972-
member public this.``Fsx.HashR_QuickInfo.ResolveFromAssemblyFoldersEx``() =
973-
let fileContent = """#r "Microsoft.VisualStudio.Shell.15.0.dll" """ // 'Microsoft.VisualStudio.Shell.15.0' is located via AssemblyFoldersEx
974-
let marker = "#r \"Microsoft.Vis"
975-
this.AssertQuickInfoContainsAtEndOfMarkerInFsxFile fileContent marker "Microsoft.VisualStudio.Shell.15.0, Version="
976-
this.AssertQuickInfoContainsAtEndOfMarkerInFsxFile fileContent marker "Microsoft.VisualStudio.Shell.15.0.dll"
977-
978980
[<Test>]
979981
[<Category("fsx closure")>]
980982
member public this.``Fsx.HashR_QuickInfo.ResolveFromFullyQualifiedPath``() =

0 commit comments

Comments
 (0)