I have two sequences (of tuples) on which I need to do a join:
- Seq 1: [(City1 * Pin1), (City2 * Pin2), (City1 * Pin3), (City1 * Pin4)]
- Seq 2: [(Pin1 * ProductA), (Pin2 * ProductB), (Pin1 * ProductC), (Pin2 * ProductA)]
into the sequence (of tuples):
- [(City1 * ProductA), (City2 * ProductB), (City * ProductC), (City2 * Product A)…]
In C# I could do this using the Linq Join extension method like:
seq1.Join(seq2, t => t.Item2, t=> t.Item1,
(t,u) => Tuple.Create(t.Item1, u.Item2))
How do I accomplish this in F#? I cannot find join on Seq there.
Edit: Actually, you can just use LINQ:
Why not use F#’s native
Seqfunctions? If you look at the docs and at this question you can simply use these instead of LINQ. Take theSeq.map2function for example:should give you what you want, where
seq1andseq2are your first and second sequences.