Skip to content

Implement allPairs on List, Seq and Array modules #989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 8, 2016

Conversation

PatrickMcDonald
Copy link
Contributor

This is an initial pull request that implements allPairs on the collections.

See fsharp/fslang-design#47 and https://github.com/fsharp/FSharpLangDesign/blob/master/RFCs/FS-1002-cartesian-product-for-collections.md

@PatrickMcDonald PatrickMcDonald changed the title Implement allPairs Implement allPairs on List, Seq and Array modules Feb 27, 2016
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please rename it to pairsSnd

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@@ -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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a less technical term than "Cartesian product" in the comment, such as "contains all pairings of elements from the first and second arrays", likewise the other three signature file comments

@dsyme
Copy link
Contributor

dsyme commented Mar 8, 2016

This looks good to me and ready to go apart from the one documentation comment above (which could perhaps be applied later)

KevinRansom added a commit that referenced this pull request Mar 8, 2016
Implement allPairs on List, Seq and Array modules
@KevinRansom KevinRansom merged commit 2ffb0b6 into dotnet:master Mar 8, 2016
@KevinRansom
Copy link
Contributor

I will take this PR as is. @PatrickMcDonald.

@hickford
Copy link

hickford commented May 11, 2018

Both https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/lists and https://msdn.microsoft.com/visualfsharpdocs/conceptual/collections.list-module-%5bfsharp%5d are missing documentation for List.allPairs . The former links to the latter "For information about additional operations on lists, see the library reference topic Collections.List Module."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants