Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
0a020aa2
F
fsharp
项目概览
dotNET Platform
/
fsharp
12 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fsharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0a020aa2
编写于
2月 21, 2016
作者:
P
Patrick McDonald
提交者:
Patrick McDonald
2月 27, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement allPairs on List, Seq and Array modules
Implements fsharp/FSharpLangDesign#47 Closes Microsoft/visualfsharp#989
上级
f481bc8b
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
206 addition
and
0 deletion
+206
-0
src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ArrayModule.fs
...s/FSharp.Core/Microsoft.FSharp.Collections/ArrayModule.fs
+28
-0
src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/CollectionModulesConsistency.fs
...rosoft.FSharp.Collections/CollectionModulesConsistency.fs
+12
-0
src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ListModule.fs
...ts/FSharp.Core/Microsoft.FSharp.Collections/ListModule.fs
+22
-0
src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ListProperties.fs
...Sharp.Core/Microsoft.FSharp.Collections/ListProperties.fs
+32
-0
src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule.fs
...sts/FSharp.Core/Microsoft.FSharp.Collections/SeqModule.fs
+27
-0
src/fsharp/FSharp.Core.Unittests/SurfaceArea.net40.fs
src/fsharp/FSharp.Core.Unittests/SurfaceArea.net40.fs
+3
-0
src/fsharp/FSharp.Core.Unittests/SurfaceArea.portable259.fs
src/fsharp/FSharp.Core.Unittests/SurfaceArea.portable259.fs
+3
-0
src/fsharp/FSharp.Core.Unittests/SurfaceArea.portable47.fs
src/fsharp/FSharp.Core.Unittests/SurfaceArea.portable47.fs
+3
-0
src/fsharp/FSharp.Core.Unittests/SurfaceArea.portable7.fs
src/fsharp/FSharp.Core.Unittests/SurfaceArea.portable7.fs
+3
-0
src/fsharp/FSharp.Core.Unittests/SurfaceArea.portable78.fs
src/fsharp/FSharp.Core.Unittests/SurfaceArea.portable78.fs
+3
-0
src/fsharp/FSharp.Core/array.fs
src/fsharp/FSharp.Core/array.fs
+12
-0
src/fsharp/FSharp.Core/array.fsi
src/fsharp/FSharp.Core/array.fsi
+8
-0
src/fsharp/FSharp.Core/list.fs
src/fsharp/FSharp.Core/list.fs
+3
-0
src/fsharp/FSharp.Core/list.fsi
src/fsharp/FSharp.Core/list.fsi
+7
-0
src/fsharp/FSharp.Core/local.fs
src/fsharp/FSharp.Core/local.fs
+24
-0
src/fsharp/FSharp.Core/local.fsi
src/fsharp/FSharp.Core/local.fsi
+1
-0
src/fsharp/FSharp.Core/seq.fs
src/fsharp/FSharp.Core/seq.fs
+7
-0
src/fsharp/FSharp.Core/seq.fsi
src/fsharp/FSharp.Core/seq.fsi
+8
-0
未找到文件。
src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ArrayModule.fs
浏览文件 @
0a020aa2
...
...
@@ -41,6 +41,34 @@ type ArrayModule() =
()
[<
Test
>]
member
this
.
AllPairs
()
=
// integer array
let
resultInt
=
Array
.
allPairs
[|
1
..
3
|]
[|
2
..
2
..
6
|]
if
resultInt
<>
[|(
1
,
2
);(
1
,
4
);(
1
,
6
)
(
2
,
2
);(
2
,
4
);(
2
,
6
)
(
3
,
2
);(
3
,
4
);(
3
,
6
)|]
then
Assert
.
Fail
()
// string array
let
resultStr
=
Array
.
allPairs
[|
"A"
;
"B"
;
"C"
;
"D"
|]
[|
"a"
;
"b"
;
"c"
;
"d"
|]
if
resultStr
<>
[|(
"A"
,
"a"
);(
"A"
,
"b"
);(
"A"
,
"c"
);(
"A"
,
"d"
)
(
"B"
,
"a"
);(
"B"
,
"b"
);(
"B"
,
"c"
);(
"B"
,
"d"
)
(
"C"
,
"a"
);(
"C"
,
"b"
);(
"C"
,
"c"
);(
"C"
,
"d"
)
(
"D"
,
"a"
);(
"D"
,
"b"
);(
"D"
,
"c"
);(
"D"
,
"d"
)|]
then
Assert
.
Fail
()
// empty array
if
Array
.
allPairs
[||]
[||]
<>
[||]
then
Assert
.
Fail
()
if
Array
.
allPairs
[|
1
..
3
|]
[||]
<>
[||]
then
Assert
.
Fail
()
if
Array
.
allPairs
[||]
[|
1
..
3
|]
<>
[||]
then
Assert
.
Fail
()
// null array
let
nullArr
=
null
:
string
[]
CheckThrowsArgumentNullException
(
fun
()
->
Array
.
allPairs
nullArr
nullArr
|>
ignore
)
CheckThrowsArgumentNullException
(
fun
()
->
Array
.
allPairs
[||]
nullArr
|>
ignore
)
CheckThrowsArgumentNullException
(
fun
()
->
Array
.
allPairs
nullArr
[||]
|>
ignore
)
()
[<
Test
>]
member
this
.
Append
()
=
// integer array
...
...
src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/CollectionModulesConsistency.fs
浏览文件 @
0a020aa2
...
...
@@ -8,6 +8,18 @@ open NUnit.Framework
open
FsCheck
open
Utils
let
allPairs
<
'
a
when
'
a
:
equality
>
(
xs
:
list
<
'
a
>)
(
xs2
:
list
<
'
a
>)
=
let
s
=
xs
|>
Seq
.
allPairs
xs2
let
l
=
xs
|>
List
.
allPairs
xs2
let
a
=
xs
|>
Seq
.
toArray
|>
Array
.
allPairs
(
Seq
.
toArray
xs2
)
Seq
.
toArray
s
=
a
&&
List
.
toArray
l
=
a
[<
Test
>]
let
``allPairs is consistent``
()
=
Check
.
QuickThrowOnFailure
allPairs
<
int
>
Check
.
QuickThrowOnFailure
allPairs
<
string
>
Check
.
QuickThrowOnFailure
allPairs
<
NormalFloat
>
let
append
<
'
a
when
'
a
:
equality
>
(
xs
:
list
<
'
a
>)
(
xs2
:
list
<
'
a
>)
=
let
s
=
xs
|>
Seq
.
append
xs2
let
l
=
xs
|>
List
.
append
xs2
...
...
src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ListModule.fs
浏览文件 @
0a020aa2
...
...
@@ -30,6 +30,28 @@ type ListModule() =
()
[<
Test
>]
member
this
.
AllPairs
()
=
// integer List
let
resultInt
=
List
.
allPairs
[
1
..
3
]
[
2
..
2
..
6
]
Assert
.
AreEqual
([(
1
,
2
);(
1
,
4
);(
1
,
6
)
(
2
,
2
);(
2
,
4
);(
2
,
6
)
(
3
,
2
);(
3
,
4
);(
3
,
6
)],
resultInt
)
// string List
let
resultStr
=
List
.
allPairs
[
2
;
3
;
4
;
5
]
[
"b"
;
"c"
;
"d"
;
"e"
]
Assert
.
AreEqual
([(
2
,
"b"
);(
2
,
"c"
);(
2
,
"d"
);(
2
,
"e"
)
(
3
,
"b"
);(
3
,
"c"
);(
3
,
"d"
);(
3
,
"e"
)
(
4
,
"b"
);(
4
,
"c"
);(
4
,
"d"
);(
4
,
"e"
)
(
5
,
"b"
);(
5
,
"c"
);(
5
,
"d"
);(
5
,
"e"
)]
,
resultStr
)
// empty List
let
resultEpt
=
List
.
allPairs
[]
[]
let
empTuple
:(
obj
*
obj
)
list
=
[]
Assert
.
AreEqual
(
empTuple
,
resultEpt
)
()
[<
Test
>]
member
this
.
Append
()
=
// integer List
...
...
src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ListProperties.fs
浏览文件 @
0a020aa2
...
...
@@ -823,3 +823,35 @@ let ``List.sumBy calculates the sum of the mapped list`` () =
Check
.
QuickThrowOnFailure
sumBy
<
int
>
Check
.
QuickThrowOnFailure
sumBy
<
string
>
Check
.
QuickThrowOnFailure
sumBy
<
float
>
let
allPairsCount
<
'
a
,
'
b
>
(
xs
:
'
a
list
)
(
ys
:
'
b
list
)
=
let
pairs
=
List
.
allPairs
xs
ys
pairs
.
Length
=
xs
.
Length
*
ys
.
Length
[<
Test
>]
let
``List.allPairs produces the correct number of pairs``
()
=
Check
.
QuickThrowOnFailure
allPairsCount
<
int
,
int
>
Check
.
QuickThrowOnFailure
allPairsCount
<
string
,
string
>
Check
.
QuickThrowOnFailure
allPairsCount
<
float
,
float
>
let
allPairsFst
<
'
a
,
'
b
when
'
a
:
equality
>
(
xs
:
'
a
list
)
(
ys
:
'
b
list
)
=
let
pairsFst
=
List
.
allPairs
xs
ys
|>
List
.
map
fst
let
check
=
xs
|>
List
.
collect
(
List
.
replicate
ys
.
Length
)
pairsFst
=
check
[<
Test
>]
let
``List.allPairs first elements are correct``
()
=
Check
.
QuickThrowOnFailure
allPairsFst
<
int
,
int
>
Check
.
QuickThrowOnFailure
allPairsFst
<
string
,
string
>
Check
.
QuickThrowOnFailure
allPairsFst
<
NormalFloat
,
NormalFloat
>
let
allPairsSnd
<
'
a
,
'
b
when
'
b
:
equality
>
(
xs
:
'
a
list
)
(
ys
:
'
b
list
)
=
let
pairsFst
=
List
.
allPairs
xs
ys
|>
List
.
map
snd
let
check
=
[
for
i
in
1
..
xs
.
Length
do
yield
!
ys
]
pairsFst
=
check
[<
Test
>]
let
``List.allPairs second elements are correct``
()
=
Check
.
QuickThrowOnFailure
allPairsFst
<
int
,
int
>
Check
.
QuickThrowOnFailure
allPairsFst
<
string
,
string
>
Check
.
QuickThrowOnFailure
allPairsFst
<
NormalFloat
,
NormalFloat
>
src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule.fs
浏览文件 @
0a020aa2
...
...
@@ -22,6 +22,33 @@ Make sure each method works on:
[<
TestFixture
>]
type
SeqModule
()
=
[<
Test
>]
member
this
.
AllPairs
()
=
// integer Seq
let
resultInt
=
Seq
.
allPairs
(
seq
[
1
..
7
])
(
seq
[
11
..
17
])
let
expectedInt
=
seq
{
for
i
in
1
..
7
do
for
j
in
11
..
17
do
yield
i
,
j
}
VerifySeqsEqual
expectedInt
resultInt
// string Seq
let
resultStr
=
Seq
.
allPairs
(
seq
[
"str3"
;
"str4"
])
(
seq
[
"str1"
;
"str2"
])
let
expectedStr
=
seq
[
"str3"
,
"str1"
;
"str3"
,
"str2"
;
"str4"
,
"str1"
;
"str4"
,
"str2"
]
VerifySeqsEqual
expectedStr
resultStr
// empty Seq
VerifySeqsEqual
Seq
.
empty
<|
Seq
.
allPairs
Seq
.
empty
Seq
.
empty
VerifySeqsEqual
Seq
.
empty
<|
Seq
.
allPairs
{
1
..
7
}
Seq
.
empty
VerifySeqsEqual
Seq
.
empty
<|
Seq
.
allPairs
Seq
.
empty
{
1
..
7
}
// null Seq
CheckThrowsArgumentNullException
(
fun
()
->
Seq
.
allPairs
null
null
|>
ignore
)
CheckThrowsArgumentNullException
(
fun
()
->
Seq
.
allPairs
null
(
seq
[
1
..
7
])
|>
ignore
)
CheckThrowsArgumentNullException
(
fun
()
->
Seq
.
allPairs
(
seq
[
1
..
7
])
null
|>
ignore
)
()
[<
Test
>]
member
this
.
CachedSeq_Clear
()
=
...
...
src/fsharp/FSharp.Core.Unittests/SurfaceArea.net40.fs
浏览文件 @
0a020aa2
...
...
@@ -100,6 +100,7 @@ Microsoft.FSharp.Collections.ArrayModule: System.Collections.Generic.IEnumerable
Microsoft.FSharp.Collections.ArrayModule: System.String ToString()
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[System.Int32,T][] Indexed[T](T[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T,T][] Pairwise[T](T[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T1,T2][] AllPairs[T1,T2](T1[], T2[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T1,T2][] Zip[T1,T2](T1[], T2[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T1[],T2[]] Unzip[T1,T2](System.Tuple`2[T1,T2][])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[TKey,System.Int32][] CountBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], T[])
...
...
@@ -296,6 +297,7 @@ Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[Microsoft.FSharp.Collections.FSharpList`1[T]] Windowed[T](Int32, Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[System.Int32,T]] Indexed[T](Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[T,T]] Pairwise[T](Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[T1,T2]] AllPairs[T1,T2](Microsoft.FSharp.Collections.FSharpList`1[T1], Microsoft.FSharp.Collections.FSharpList`1[T2])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[T1,T2]] Zip[T1,T2](Microsoft.FSharp.Collections.FSharpList`1[T1], Microsoft.FSharp.Collections.FSharpList`1[T2])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[TKey,Microsoft.FSharp.Collections.FSharpList`1[T]]] GroupBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[TKey,System.Int32]] CountBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], Microsoft.FSharp.Collections.FSharpList`1[T])
...
...
@@ -432,6 +434,7 @@ Microsoft.FSharp.Collections.SeqModule: Microsoft.FSharp.Core.FSharpOption`1[T]
Microsoft.FSharp.Collections.SeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryLast[T](System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[System.Int32,T]] Indexed[T](System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[T,T]] Pairwise[T](System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[T1,T2]] AllPairs[T1,T2](System.Collections.Generic.IEnumerable`1[T1], System.Collections.Generic.IEnumerable`1[T2])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[T1,T2]] Zip[T1,T2](System.Collections.Generic.IEnumerable`1[T1], System.Collections.Generic.IEnumerable`1[T2])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[TKey,System.Collections.Generic.IEnumerable`1[T]]] GroupBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[TKey,System.Int32]] CountBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], System.Collections.Generic.IEnumerable`1[T])
...
...
src/fsharp/FSharp.Core.Unittests/SurfaceArea.portable259.fs
浏览文件 @
0a020aa2
...
...
@@ -87,6 +87,7 @@ Microsoft.FSharp.Collections.ArrayModule: System.Collections.Generic.IEnumerable
Microsoft.FSharp.Collections.ArrayModule: System.String ToString()
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[System.Int32,T][] Indexed[T](T[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T,T][] Pairwise[T](T[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T1,T2][] AllPairs[T1,T2](T1[], T2[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T1,T2][] Zip[T1,T2](T1[], T2[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T1[],T2[]] Unzip[T1,T2](System.Tuple`2[T1,T2][])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[TKey,System.Int32][] CountBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], T[])
...
...
@@ -283,6 +284,7 @@ Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[Microsoft.FSharp.Collections.FSharpList`1[T]] Windowed[T](Int32, Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[System.Int32,T]] Indexed[T](Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[T,T]] Pairwise[T](Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[T1,T2]] AllPairs[T1,T2](Microsoft.FSharp.Collections.FSharpList`1[T1], Microsoft.FSharp.Collections.FSharpList`1[T2])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[T1,T2]] Zip[T1,T2](Microsoft.FSharp.Collections.FSharpList`1[T1], Microsoft.FSharp.Collections.FSharpList`1[T2])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[TKey,Microsoft.FSharp.Collections.FSharpList`1[T]]] GroupBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[TKey,System.Int32]] CountBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], Microsoft.FSharp.Collections.FSharpList`1[T])
...
...
@@ -419,6 +421,7 @@ Microsoft.FSharp.Collections.SeqModule: Microsoft.FSharp.Core.FSharpOption`1[T]
Microsoft.FSharp.Collections.SeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryLast[T](System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[System.Int32,T]] Indexed[T](System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[T,T]] Pairwise[T](System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[T1,T2]] AllPairs[T1,T2](System.Collections.Generic.IEnumerable`1[T1], System.Collections.Generic.IEnumerable`1[T2])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[T1,T2]] Zip[T1,T2](System.Collections.Generic.IEnumerable`1[T1], System.Collections.Generic.IEnumerable`1[T2])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[TKey,System.Collections.Generic.IEnumerable`1[T]]] GroupBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[TKey,System.Int32]] CountBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], System.Collections.Generic.IEnumerable`1[T])
...
...
src/fsharp/FSharp.Core.Unittests/SurfaceArea.portable47.fs
浏览文件 @
0a020aa2
...
...
@@ -84,6 +84,7 @@ Microsoft.FSharp.Collections.ArrayModule: System.Collections.Generic.IEnumerable
Microsoft.FSharp.Collections.ArrayModule: System.String ToString()
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[System.Int32,T][] Indexed[T](T[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T,T][] Pairwise[T](T[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T1,T2][] AllPairs[T1,T2](T1[], T2[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T1,T2][] Zip[T1,T2](T1[], T2[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T1[],T2[]] Unzip[T1,T2](System.Tuple`2[T1,T2][])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[TKey,System.Int32][] CountBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], T[])
...
...
@@ -280,6 +281,7 @@ Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[Microsoft.FSharp.Collections.FSharpList`1[T]] Windowed[T](Int32, Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[System.Int32,T]] Indexed[T](Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[T,T]] Pairwise[T](Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[T1,T2]] AllPairs[T1,T2](Microsoft.FSharp.Collections.FSharpList`1[T1], Microsoft.FSharp.Collections.FSharpList`1[T2])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[T1,T2]] Zip[T1,T2](Microsoft.FSharp.Collections.FSharpList`1[T1], Microsoft.FSharp.Collections.FSharpList`1[T2])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[TKey,Microsoft.FSharp.Collections.FSharpList`1[T]]] GroupBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[TKey,System.Int32]] CountBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], Microsoft.FSharp.Collections.FSharpList`1[T])
...
...
@@ -416,6 +418,7 @@ Microsoft.FSharp.Collections.SeqModule: Microsoft.FSharp.Core.FSharpOption`1[T]
Microsoft.FSharp.Collections.SeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryLast[T](System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[System.Int32,T]] Indexed[T](System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[T,T]] Pairwise[T](System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[T1,T2]] AllPairs[T1,T2](System.Collections.Generic.IEnumerable`1[T1], System.Collections.Generic.IEnumerable`1[T2])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[T1,T2]] Zip[T1,T2](System.Collections.Generic.IEnumerable`1[T1], System.Collections.Generic.IEnumerable`1[T2])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[TKey,System.Collections.Generic.IEnumerable`1[T]]] GroupBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[TKey,System.Int32]] CountBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], System.Collections.Generic.IEnumerable`1[T])
...
...
src/fsharp/FSharp.Core.Unittests/SurfaceArea.portable7.fs
浏览文件 @
0a020aa2
...
...
@@ -100,6 +100,7 @@ Microsoft.FSharp.Collections.ArrayModule: System.Collections.Generic.IEnumerable
Microsoft.FSharp.Collections.ArrayModule: System.String ToString()
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[System.Int32,T][] Indexed[T](T[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T,T][] Pairwise[T](T[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T1,T2][] AllPairs[T1,T2](T1[], T2[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T1,T2][] Zip[T1,T2](T1[], T2[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T1[],T2[]] Unzip[T1,T2](System.Tuple`2[T1,T2][])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[TKey,System.Int32][] CountBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], T[])
...
...
@@ -296,6 +297,7 @@ Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[Microsoft.FSharp.Collections.FSharpList`1[T]] Windowed[T](Int32, Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[System.Int32,T]] Indexed[T](Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[T,T]] Pairwise[T](Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[T1,T2]] AllPairs[T1,T2](Microsoft.FSharp.Collections.FSharpList`1[T1], Microsoft.FSharp.Collections.FSharpList`1[T2])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[T1,T2]] Zip[T1,T2](Microsoft.FSharp.Collections.FSharpList`1[T1], Microsoft.FSharp.Collections.FSharpList`1[T2])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[TKey,Microsoft.FSharp.Collections.FSharpList`1[T]]] GroupBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[TKey,System.Int32]] CountBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], Microsoft.FSharp.Collections.FSharpList`1[T])
...
...
@@ -432,6 +434,7 @@ Microsoft.FSharp.Collections.SeqModule: Microsoft.FSharp.Core.FSharpOption`1[T]
Microsoft.FSharp.Collections.SeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryLast[T](System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[System.Int32,T]] Indexed[T](System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[T,T]] Pairwise[T](System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[T1,T2]] AllPairs[T1,T2](System.Collections.Generic.IEnumerable`1[T1], System.Collections.Generic.IEnumerable`1[T2])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[T1,T2]] Zip[T1,T2](System.Collections.Generic.IEnumerable`1[T1], System.Collections.Generic.IEnumerable`1[T2])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[TKey,System.Collections.Generic.IEnumerable`1[T]]] GroupBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[TKey,System.Int32]] CountBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], System.Collections.Generic.IEnumerable`1[T])
...
...
src/fsharp/FSharp.Core.Unittests/SurfaceArea.portable78.fs
浏览文件 @
0a020aa2
...
...
@@ -87,6 +87,7 @@ Microsoft.FSharp.Collections.ArrayModule: System.Collections.Generic.IEnumerable
Microsoft.FSharp.Collections.ArrayModule: System.String ToString()
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[System.Int32,T][] Indexed[T](T[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T,T][] Pairwise[T](T[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T1,T2][] AllPairs[T1,T2](T1[], T2[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T1,T2][] Zip[T1,T2](T1[], T2[])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[T1[],T2[]] Unzip[T1,T2](System.Tuple`2[T1,T2][])
Microsoft.FSharp.Collections.ArrayModule: System.Tuple`2[TKey,System.Int32][] CountBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], T[])
...
...
@@ -283,6 +284,7 @@ Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[Microsoft.FSharp.Collections.FSharpList`1[T]] Windowed[T](Int32, Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[System.Int32,T]] Indexed[T](Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[T,T]] Pairwise[T](Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[T1,T2]] AllPairs[T1,T2](Microsoft.FSharp.Collections.FSharpList`1[T1], Microsoft.FSharp.Collections.FSharpList`1[T2])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[T1,T2]] Zip[T1,T2](Microsoft.FSharp.Collections.FSharpList`1[T1], Microsoft.FSharp.Collections.FSharpList`1[T2])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[TKey,Microsoft.FSharp.Collections.FSharpList`1[T]]] GroupBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[TKey,System.Int32]] CountBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], Microsoft.FSharp.Collections.FSharpList`1[T])
...
...
@@ -419,6 +421,7 @@ Microsoft.FSharp.Collections.SeqModule: Microsoft.FSharp.Core.FSharpOption`1[T]
Microsoft.FSharp.Collections.SeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryLast[T](System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[System.Int32,T]] Indexed[T](System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[T,T]] Pairwise[T](System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[T1,T2]] AllPairs[T1,T2](System.Collections.Generic.IEnumerable`1[T1], System.Collections.Generic.IEnumerable`1[T2])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[T1,T2]] Zip[T1,T2](System.Collections.Generic.IEnumerable`1[T1], System.Collections.Generic.IEnumerable`1[T2])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[TKey,System.Collections.Generic.IEnumerable`1[T]]] GroupBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], System.Collections.Generic.IEnumerable`1[T])
Microsoft.FSharp.Collections.SeqModule: System.Collections.Generic.IEnumerable`1[System.Tuple`2[TKey,System.Int32]] CountBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], System.Collections.Generic.IEnumerable`1[T])
...
...
src/fsharp/FSharp.Core/array.fs
浏览文件 @
0a020aa2
...
...
@@ -648,6 +648,18 @@ namespace Microsoft.FSharp.Collections
res
.[
i
]
<-
(
array1
.[
i
],
array2
.[
i
],
array3
.[
i
])
res
[<
CompiledName
(
"AllPairs"
)>]
let
allPairs
(
array1
:
_[])
(
array2
:
_[])
=
checkNonNull
"array1"
array1
checkNonNull
"array2"
array2
let
len1
=
array1
.
Length
let
len2
=
array2
.
Length
let
res
=
Microsoft
.
FSharp
.
Primitives
.
Basics
.
Array
.
zeroCreateUnchecked
(
len1
*
len2
)
for
i
=
0
to
len1
-
1
do
for
j
=
0
to
len2
-
1
do
res
.[
i
*
len2
+
j
]
<-
(
array1
.[
i
],
array2
.[
j
])
res
[<
CompiledName
(
"Unfold"
)>]
let
unfold
<
'
T
,
'
State
>
(
f
:
'
State
->
(
'
T
*
'
State
)
option
)
(
s
:
'
State
)
=
let
res
=
ResizeArray
<_>()
...
...
src/fsharp/FSharp.Core/array.fsi
浏览文件 @
0a020aa2
...
...
@@ -12,6 +12,14 @@ namespace Microsoft.FSharp.Collections
[<
RequireQualifiedAccess
>]
module
Array
=
/// <summary>Builds a new array that contains the cartesian product of the two input arrays.</summary>
/// <param name="array1">The first input array.</param>
/// <param name="array2">The second input array.</param>
/// <exception cref="System.ArgumentNullException">Thrown when either of the input arrays is null.</exception>
/// <returns>The resulting array of pairs.</returns>
[<
CompiledName
(
"AllPairs"
)>]
val
allPairs
:
array1
:
'
T1
[]
->
array2
:
'
T2
[]
->
(
'
T1
*
'
T2
)[]
/// <summary>Builds a new array that contains the elements of the first array followed by the elements of the second array.</summary>
/// <param name="array1">The first input array.</param>
/// <param name="array2">The second input array.</param>
...
...
src/fsharp/FSharp.Core/list.fs
浏览文件 @
0a020aa2
...
...
@@ -616,6 +616,9 @@ namespace Microsoft.FSharp.Collections
[<
CompiledName
(
"Collect"
)>]
let
collect
f
list
=
Microsoft
.
FSharp
.
Primitives
.
Basics
.
List
.
collect
f
list
[<
CompiledName
(
"AllPairs"
)>]
let
allPairs
list1
list2
=
Microsoft
.
FSharp
.
Primitives
.
Basics
.
List
.
allPairs
list1
list2
[<
CompiledName
(
"CompareWith"
)>]
let
inline
compareWith
(
comparer
:
'
T
->
'
T
->
int
)
(
list1
:
'
T
list
)
(
list2
:
'
T
list
)
=
let
rec
loop
list1
list2
=
...
...
src/fsharp/FSharp.Core/list.fsi
浏览文件 @
0a020aa2
...
...
@@ -12,6 +12,13 @@ namespace Microsoft.FSharp.Collections
[<
RequireQualifiedAccess
>]
module
List
=
/// <summary>Returns a new list that contains the cartesian product of the two input lists.</summary>
/// <param name="list1">The first input list.</param>
/// <param name="list2">The second input list.</param>
/// <returns>The resulting list of pairs.</returns>
[<
CompiledName
(
"AllPairs"
)>]
val
allPairs
:
list1
:
'
T1
list
->
list2
:
'
T2
list
->
(
'
T1
*
'
T2
)
list
/// <summary>Returns a new list that contains the elements of the first list
/// followed by elements of the second.</summary>
/// <param name="list1">The first input list.</param>
...
...
src/fsharp/FSharp.Core/local.fs
浏览文件 @
0a020aa2
...
...
@@ -224,6 +224,30 @@ module internal List =
collectToFreshConsTail
f
list
cons
cons
.
Tail
let
rec
allPairsToFreshConsTailSingle
x
ys
cons
=
match
ys
with
|
[]
->
cons
|
(
h2
::
t2
)
->
let
cons2
=
freshConsNoTail
(
x
,
h2
)
setFreshConsTail
cons
cons2
allPairsToFreshConsTailSingle
x
t2
cons2
let
rec
allPairsToFreshConsTail
xs
ys
cons
=
match
xs
with
|
[]
->
setFreshConsTail
cons
[]
|
(
h
::
t
)
->
let
p
=
allPairsToFreshConsTailSingle
h
ys
cons
allPairsToFreshConsTail
t
ys
p
let
allPairs
(
xs
:
'
T
list
)
(
ys
:
'
U
list
)
=
match
xs
,
ys
with
|
_,
[]
->
[]
|
[]
,
_
->
[]
|
_
->
let
cons
=
freshConsNoTail
(
Unchecked
.
defaultof
<
'
T
*
'
U
>)
allPairsToFreshConsTail
xs
ys
cons
cons
.
Tail
// optimized mutation-based implementation. This code is only valid in fslib, where mutation of private
// tail cons cells is permitted in carefully written library code.
let
rec
filterToFreshConsTail
cons
f
l
=
...
...
src/fsharp/FSharp.Core/local.fsi
浏览文件 @
0a020aa2
...
...
@@ -7,6 +7,7 @@ open Microsoft.FSharp.Core
open
Microsoft
.
FSharp
.
Collections
module
internal
List
=
val
allPairs
:
'
T1
list
->
'
T2
list
->
(
'
T1
*
'
T2
)
list
val
distinctWithComparer
:
System
.
Collections
.
Generic
.
IEqualityComparer
<
'
T
>
->
'
T
list
->
'
T
list
val
distinctByWithComparer
:
System
.
Collections
.
Generic
.
IEqualityComparer
<
'
Key
>
->
(
'
T
->
'
Key
)
->
list
:
'
T
list
->
'
T
list
when
'
Key
:
equality
val
init
:
int
->
(
int
->
'
T
)
->
'
T
list
...
...
src/fsharp/FSharp.Core/seq.fs
浏览文件 @
0a020aa2
...
...
@@ -1442,6 +1442,13 @@ namespace Microsoft.FSharp.Collections
enumeratorR
:=
None
)
(
new
CachedSeq
<_>(
cleanup
,
result
)
:>
seq
<_>)
[<
CompiledName
(
"AllPairs"
)>]
let
allPairs
source1
source2
=
checkNonNull
"source1"
source1
checkNonNull
"source2"
source2
let
cached
=
cache
source2
source1
|>
collect
(
fun
x
->
cached
|>
map
(
fun
y
->
x
,
y
))
[<
CodeAnalysis
.
SuppressMessage
(
"Microsoft.Naming"
,
"CA1709:IdentifiersShouldBeCasedCorrectly"
);
CodeAnalysis
.
SuppressMessage
(
"Microsoft.Naming"
,
"CA1707:IdentifiersShouldNotContainUnderscores"
);
CodeAnalysis
.
SuppressMessage
(
"Microsoft.Naming"
,
"CA1704:IdentifiersShouldBeSpelledCorrectly"
)>]
[<
CompiledName
(
"ReadOnly"
)>]
let
readonly
(
source
:
seq
<_>)
=
...
...
src/fsharp/FSharp.Core/seq.fsi
浏览文件 @
0a020aa2
...
...
@@ -14,6 +14,14 @@ namespace Microsoft.FSharp.Collections
[<
CompilationRepresentation
(
CompilationRepresentationFlags
.
ModuleSuffix
)>]
module
Seq
=
/// <summary>Returns a new sequence that contains the cartesian product of the two input sequences.</summary>
/// <param name="source1">The first sequence.</param>
/// <param name="source2">The second sequence.</param>
/// <returns>The result sequence.</returns>
/// <exception cref="System.ArgumentNullException">Thrown when either of the input sequences is null.</exception>
[<
CompiledName
(
"AllPairs"
)>]
val
allPairs
:
source1
:
seq
<
'
T1
>
->
source2
:
seq
<
'
T2
>
->
seq
<
'
T1
*
'
T2
>
/// <summary>Wraps the two given enumerations as a single concatenated
/// enumeration.</summary>
///
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录