I’ve got a project that I’m trying to convert to F#, with a fair amount of linq-to-IEnumerable style queries in it. I’m curious what the most elegant way of doing a join of multiple lists would be in F#. For instance if I have a bunch of C# code like the following
var joinedList =
from val1 in list1
join val2 in list2 on val1.Key equals val2.Parent
join val3 in list3 on val1.Key equals val3.Parent
orderby val1
select new {val1, val2, val3};
what would be the best way to translate this to F#? I’ll leave open the definition of “best”, but I’m looking for something functional rather than imperative, and preferably without converting my lists to seqs and/or importing System.Linq. Both lazy and eager solutions would be useful. And of course reusability is key, since I have queries like this all over. If there’s any way of using workflows to make the syntax more elegant, that would be great too.
Well, in Don’s blog about LINQ and the Powerpack:
Link
it shows off how to do LINQ join calls. But of course that’s on
seqs and using LINQ. He also points out that a join is like a conditional. So I think e.g. your example is likethough I haven’t verified it on real data.